study: use checkedint as a drop-in replacement of native long
Gregor Mückl
gregormueckl at gmx.de
Wed Mar 24 18:38:07 UTC 2021
On Wednesday, 24 March 2021 at 17:38:14 UTC, H. S. Teoh wrote:
> Since there is only one sensible meaning of `a = b = c`...
If I'm reading the spec on expressions right, the compiler is
actually free to interpret that as (a = b) = c if it feels
particularly adventurous. The evaluation order of assignment
operations is explicitly undefined...
I think the intent was to not force an order of execution of
subexpressions on either side of a single assignment (e.g. a[i] =
a[j] with an opIndex implementation), but this seems to leave too
much leeway for assignment chains.
Side note: having an undefined order of execution of the sides of
an assignment can be a great source of fun (read: surprising)
bugs in C++. Just going from GCC to clang switches the order
around.
More information about the Digitalmars-d
mailing list