Bug in ^^

Brett Brett at gmail.com
Tue Sep 17 17:23:06 UTC 2019

On Tuesday, 17 September 2019 at 17:05:33 UTC, bachmeier wrote:
> On Tuesday, 17 September 2019 at 16:50:29 UTC, Brett wrote:
>> Wrong:
>> import std.stdio;
>> enum x = 100000000000000000;
>> enum y = 10^^17;
>> void main()
>> {
>>     ulong xx = x;
>>     ulong yy = y;
>>     writeln(x);
>>     writeln(y);
>>     writeln(xx);
>>     writeln(yy);
>> }
>> 100000000000000000
>> 1569325056
>> 100000000000000000
>> 1569325056
>> I gave code to prove that I was right, why is it so difficult 
>> for people to accept? All I see is people trying to justify 
>> the compilers current behavior rather than think for 
>> themselves and realize something wrong!
>> This not a difficult issue.
> That output looks correct to me.

enum x = 100000000000000000;
enum y = 10^^17;

Why do you think 10^^17 and 100000000000000000

should be different?

First I'm told that enum's are ints and so 10^17 should wrap... 
yet 100000000000000000 is not wrapped(yet you say it looks 

then I'm told I have to use L's to get it to not wrap, yet


does not have L... and it doesn't wrap(so the L is implicit).

So which is it?

Do you not understand that something is going on that makes no 
sense and this creates problems? It doesn't make sense... even if 
you think it does.

Either the compiler needs to warn or there has to be a consistent 
behavior and there clearly is not consistent behavior... just 
because it makes sense to you it only means that you are choosing 
the behavior the compiler uses, but the compiler can be wrong and 
hence that means you would be wrong too.

More information about the Digitalmars-d mailing list