Bug in shifting

Steven Schveighoffer schveiguy at gmail.com
Fri Dec 14 01:56:33 UTC 2018


On 12/13/18 7:16 PM, Michelle Long wrote:
> byte x = 0xF;
> ulong y = x >> 60;

Surely you meant x << 60? As x >> 60 is going to be 0, even with a ulong.

> 
> Does not compute the proper value.
> 
> It seems that the shift amount is wrapped. My code is more complex. The 
> code above does give an error. I am using the code in a template. If I 
> change x to ulong it works as expected.

Given that your code above doesn't compile, it's hard to figure out what 
you mean. Do you have a working example?

> I've noticed the compiler is not throwing up errors and warnings like it 
> used to:
> 
> I thought D required breaks for cases? Seems it doesn't any longer! I'm 
> only using -g -gf -d

It doesn't require breaks for cases, it requires no fall-through on 
cases. Again, an example would help describe what you mean.

-Steve


More information about the Digitalmars-d-learn mailing list