[Bug c/51834] -Wsequence-point fails when convoluted expressions with multiple side effects are used

prasoonsaurav.nit at gmail dot com gcc-bugzilla@gcc.gnu.org
Thu Jan 12 09:08:00 GMT 2012


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51834

--- Comment #2 from Prasoon <prasoonsaurav.nit at gmail dot com> 2012-01-12 09:07:52 UTC ---
@Richard Guenther 

Considering the expression i += (i,i++,i) +i;

(i,i++,i) involves change in the value of i, however comma introduces a
sequence point so very roughly considering it equivalent to
func(_some_side_effect_on_i)

we have i += func(_some_side_effect_on_i) + i;

Do you still think the behavior is well defined?

Another C++ example would be ++a = 10; where 'a'is of type int.
This invokes UB but there is no warning from the compiler side even after we
use this flag. Raising a similar bug for C++ because the differ may be
different in C and C++.

Thanks
Prasoon



More information about the Gcc-bugs mailing list