phobos's circle CI runs a busted version of DMD
Salih Dincer
salihdb at hotmail.com
Wed Jan 11 23:54:20 UTC 2023
On Wednesday, 11 January 2023 at 23:22:04 UTC, Walter Bright
wrote:
> On 1/11/2023 12:55 PM, Paul Backus wrote:
>> If we rewrite deadalnix's example using this equivalence, we
>> get the following code:
>>
>> ushort ee = 1028;
>> ee = cast(ushort)(ee << 5U);
>> ee = cast(ushort)(ee >> 5U);
>> writeln(ee);
>>
>> ...which prints 1028. So the behavior of the original example
>> is unambiguously a violation of the language spec.
>
> That's right. It also happens for ubyte operations.
```d
ubyte u = 128;
u.writef!"%08b: "; writeln(u);
typeof(u >> 1U).stringof.writeln;
u >>= 1U;
u.writef!"%08b: "; writeln(u);
byte b = -128;
b.writef!"%08b: "; writeln(b);
typeof(b >> 1U).stringof.writeln;
b >>= 1U;
b.writef!"%08b: "; writeln(b);
```
The problem is that it shift via int first. Then the type is
converted to whatever it is, right? I think there is no error
because >>> should be used instead of >>
```d
u >>>= 1U;
assert( u == 64 );
```
SDB at 79
More information about the Digitalmars-d
mailing list