[dmd-internals] case hashOf(string literal) doesn't compile

Walter Bright via dmd-internals dmd-internals at puremagic.com
Tue Jul 26 22:53:35 PDT 2016


Please post bugs to bugzilla!

https://issues.dlang.org/enter_bug.cgi

On 7/26/2016 9:57 PM, cy via dmd-internals wrote:
> void main() {
>     pragma(msg,"bar".sizeof);
>     size_t foo = 12;
>     switch(foo) {
>     case hashOf("bar"):
>         break;
>     }
> }
>
> I'm pretty sure this worked before. (htmld is full of these hash case
> statements.) But now, when I try to compile, it spits out errors like
>
> druntime/import/object.d(3173): Error: pointer slice [0..16] exceeds allocated
> memory block [0..3]
> druntime/import/object.d(3173):        called from here: hashOf(& arg[0..16], seed)
> test.d(5):        called from here: hashOf("bar", 0LU)
>
> I'm not sure, but I think "bar".sizeof is supposed to evaluate to 3 at compile
> time, rather than 16 regardless of the string's length.
> _______________________________________________
> dmd-internals mailing list
> dmd-internals at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/dmd-internals


More information about the dmd-internals mailing list