Validity of cast(void*)size_t.max

Nordlöw per.nordlow at gmail.com
Mon Mar 5 14:01:59 UTC 2018


On Monday, 5 March 2018 at 12:41:06 UTC, Steven Schveighoffer 
wrote:
> pragma(inline, true)
> C lazyDeleted() pure nothrow @trusted { return 
> cast(C)((cast(size_t*)null) + 1); }

I still can't evaluate at compile-though...

         enum holeKeyOffset = 0x1;

         pragma(inline, true)
         static K holeKey() @trusted pure nothrow @nogc
         {
             return cast(K)((cast(size_t*)null) + holeKeyOffset);
         }

         enum _ = holeKey;

fails as

     Error: cannot perform pointer arithmetic on non-arrays at 
compile time



More information about the Digitalmars-d-learn mailing list