Is the behaviour of shift expressions with negative left operands defined / portable?

Harry Gillanders ayjsy47yyz8 at temp.mailbox.org
Tue Apr 28 20:30:27 UTC 2020


The spec doesn't seem to explicitly mention what happens when the 
left operand
of a shift expression is signed and negative. [1]
But I know that D follows C's semantics for this sort of stuff, 
and the C
standard specifies that the result of a negative left operand is 
undefined
for `<<`, and implementation-defined for `>>`. [2][3]

Is D's behaviour the same as C in this regard?

[1]: https://dlang.org/spec/expression.html#shift_expressions
[2]: https://port70.net/~nsz/c/c89/c89-draft.html#3.3.7
[3]: https://port70.net/~nsz/c/c11/n1570.html#6.5.7



More information about the Digitalmars-d-learn mailing list