Warn about do nothing expressions?
Ali Çehreli
acehreli at yahoo.com
Fri Mar 28 14:56:51 PDT 2014
On 03/28/2014 01:59 PM, Justin Whear wrote:
> $ clang test.c && ./a.out
> test.c:7:7: warning: multiple unsequenced modifications to 'i' [-
> Wunsequenced]
> i = i++;
> ~ ^
> 1 warning generated.
> 0
>
>
> Both gcc and clang agree that in C, assigning a post-increment to itself
> results in the original value.
The result of a test program cannot be proof of that. In fact, changing
the value of a variable more than once between two sequence points is
undefined behavior.
> At least Clang warns, which is good,
It is unfortunate that Clang does not use the word "undefined" there.
> but D is consistent with C's behavior on this point.
It is undefined behavior in both languages.
Ali
More information about the Digitalmars-d
mailing list