On 2/28/18 3:00 PM, Kagamin wrote:
On Tuesday, 27 February 2018 at 19:56:44 UTC, Steven Schveighoffer wrote:
cast(void*)1 is likely to be unused.

And since there was a word about class, cast(Class)cast(void*)1 won't compile :)

Oh, and it has a horrible message! Says you can't cast void * to Class. Which you can do, but apparently not if the compiler can tell if it's an integer you are casting from.

This does work:

auto x = cast(Object)((cast(size_t *)null) + 1);

I used size_t instead of ubyte, because it will avoid any weird bus errors on certain platforms. You'll just get a segfault.

-Steve
  • Validity of cast(void*)size_t... Nordlöw via Digitalmars-d-learn
    • Re: Validity of cast(voi... Steven Schveighoffer via Digitalmars-d-learn
      • Re: Validity of cast... Nordlöw via Digitalmars-d-learn
        • Re: Validity of ... Steven Schveighoffer via Digitalmars-d-learn
          • Re: Validity... Ali Çehreli via Digitalmars-d-learn
            • Re: Val... Nordlöw via Digitalmars-d-learn
              • Re:... Kagamin via Digitalmars-d-learn
              • Re:... Ali Çehreli via Digitalmars-d-learn
          • Re: Validity... Kagamin via Digitalmars-d-learn
            • Re: Val... Steven Schveighoffer via Digitalmars-d-learn
              • Re:... Nordlöw via Digitalmars-d-learn
                • ... Steven Schveighoffer via Digitalmars-d-learn
              • Re:... Nordlöw via Digitalmars-d-learn
                • ... Steven Schveighoffer via Digitalmars-d-learn
                • ... Nordlöw via Digitalmars-d-learn
                • ... Steven Schveighoffer via Digitalmars-d-learn
                • ... Nordlöw via Digitalmars-d-learn
                • ... Stefan Koch via Digitalmars-d-learn
                • ... Steven Schveighoffer via Digitalmars-d-learn
                • ... Kagamin via Digitalmars-d-learn

Reply via email to