phobos's circle CI runs a busted version of DMD
Ali Çehreli
acehreli at yahoo.com
Thu Jan 12 04:01:13 UTC 2023
On 1/11/23 15:54, Salih Dincer wrote:
> The problem is that it shift via int first.
Yes but it shouldn't because one of the operands is uint and the 'int'
operand should be converted to uint and the operation should have uint
semantics.
> I think there is no error
This is a bug because the >> operator should not perform sign extension
for unsigned types.
> because >>> should
> be used instead of >>
>>> could be used but it is the same as >> operator for unsigned types.
import std;
void main() {
int i = 0x8000_0000;
assert(i >> 31 == 0xffff_ffff); // sign extended
assert(i >>> 31 == 0x0000_0001); // different for int
uint u = 0x8000_0000;
assert(u >> 31 == 0x0000_0001); // no extension
assert(u >>> 31 == 0x0000_0001); // no difference for uint
}
Ali
More information about the Digitalmars-d
mailing list