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

cy via dmd-internals dmd-internals at puremagic.com
Sun Jul 31 11:28:34 PDT 2016


On Wednesday, 27 July 2016 at 05:53:35 UTC, Walter Bright wrote:
> Please post bugs to bugzilla!

Whoops, my bad. I was wondering where to post it.

On Thursday, 28 July 2016 at 13:15:28 UTC, Steven Schveighoffer 
wrote:
>> 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.
>
> I think you have that backwards. “bar” is an immutable(char)[], 
> which is a struct with a pointer and a size_t. Should be 16.

Well, it would be more useful if it was a char[3]. Since the 
compiler can predict the string's length already, I don't know 
why they'd stop defining it as such. But if they don't anymore, I 
guess there's not much to be done about it.

> Note, this compiles with latest released compiler, so it should 
> be flagged a regression.

I just updated on the 27th, with the last change to dmd on the 
25th. I'll update again though, thanks. Good to know it's already 
fixed!

Admittedly, one should never have to do case hashOf("literal") 
since case "literal" already computes the hash of it so maybe it 
should be a bug submitted to htmld too. It may be slightly more 
efficient to _store_ an explicitly hashed string though, as you 
only have to hang onto the size_t hash, not the whole string.


More information about the dmd-internals mailing list