phobos's circle CI runs a busted version of DMD
Dukc
ajieskola at gmail.com
Wed Jan 11 13:26:57 UTC 2023
On Wednesday, 11 January 2023 at 01:03:33 UTC, deadalnix wrote:
> Sample code:
> ```d
> ushort ee = 1028;
> ee <<= 5U;
> ee >>= 5U;
> writeln(ee);
> ```
>
> Regular compiler: https://godbolt.org/z/TcbjP76fW (prints 1028)
> Circle CI: 64516 .
>
> Someone, the compiler manages to do a signed arithmetic shift
> on an unsigned.
[The spec
says](https://dlang.org/spec/expression.html#shift_expressions)
that `>>` means *signed* shift right. `>>>` is for unsigned
shifts. So pedantically speaking, 64516 is the correct result.
It's another issue whether that's good design though. For one, it
breaks the rule "do what C does, or don't compile". It'd be more
reasonable if `>>` was type-dependant shift right (as in C) IMO.
More information about the Digitalmars-d
mailing list