https://issues.dlang.org/show_bug.cgi?id=18495
Steven Schveighoffer changed:
What|Removed |Added
Status|NEW |RESOLVED
CC||schvei...@yahoo.com
Resolution|--- |INVALID
--- Comment #2 from Steven Schveighoffer ---
This is recent, and as designed.
Please see: https://dlang.org/changelog/2.078.0.html#fix16997
See the original bug report here:
https://issues.dlang.org/show_bug.cgi?id=16997
Note that in C:
unsigned char x = 0x80;
int y = ~x; // 0xff7f
In D, without any switches:
ubyte x = 0x80;
int y = ~x; // 0x007f
With the intpromote switch, it's the same as C. This is the point behind the
change -- it was a bug that the integer promotion didn't happen before the
complement.
Yes, in C, you don't have to cast an int back down to unsigned char explicitly,
it just truncates without complaint. D does not. This is the difference you are
seeing that requires the cast.
--