Seems to have been fixed in git HEAD (46e495b), tested on Linux/64bit. Could you verify if it's also fixed on Windows?
Comment #2 by hsteoh — 2013-08-30T12:00:28Z
In fact, all versions of dmd from 2.063.2 up to commit 50a484a60cc3794281a98c51346fc0dfacfc0f24 (Fix Issue 5943 - Power expression optimisation: 2^^unsigned ==> 1<<unsigned) displayed an error message of the form:
test.d(3): Error: must import std.math to use ^^ operator
and all versions thereafter (that I tested) simply compiles it with no error. Maybe it was an intermittent failure that was quickly fixed, or maybe it only happens with specific compiler flags, or maybe it's Windows-specific?
Comment #3 by bearophile_hugs — 2013-08-30T13:36:04Z
(In reply to comment #1)
> Seems to have been fixed in git HEAD (46e495b), tested on Linux/64bit. Could
> you verify if it's also fixed on Windows?
I see the same error (Windows 32, no compilation switches):
Internal error: backend\cgcod.c 1561
Comment #4 by hsteoh — 2013-08-30T13:48:35Z
OK, must be a Windows-specific problem then. Sorry, can't help you there (don't have a Windows dev machine). :-(
Comment #5 by yebblies — 2013-09-06T07:08:45Z
A quick look shows that:
void main() {
ulong x = 1;
ulong y = 2 ^^ x;
}
Is expanded to:
ulong x = 1LU;
ulong y = 1LU << x * 1LU;
return 0;
while
void main() {
ulong x = 1LU;
ulong y = 1LU << x * 1LU;
}
is expanded to
ulong x = 1LU;
ulong y = 1LU << cast(int)(x * 1LU);
return 0;
And it seems the register allocator (or something) can't handle a ulong shift amount. Usually, a cast to int is inserted during semantic on the ShlExp, but as this one was created during optimize, it never happened.
https://github.com/D-Programming-Language/dmd/pull/2528
Comment #6 by github-bugzilla — 2013-09-12T04:26:48Z