http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50364
Richard Guenther <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution| |INVALID --- Comment #2 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-10-13 08:43:10 UTC --- That works as designed. See the recent discussion about this very topic on the gcc mailinglist and 2010-08-19 Nathan Sidwell <nat...@codesourcery.com> Richard Guenther <richard.guent...@gmail.com> * gimplify.c (gimplify_modify_expr): When assigning to volatiles, copy the src value and return a copy. * doc/extend.texi (Volatiles): Move from C++ to C and expand. (C++ Volatiles): Adjust to describe C++ semantics only. esp. "Assignments are also expressions and have an rvalue. However when assigning to a scalar volatile, the volatile object is not reread, regardless of whether the assignment expression's rvalue is used or not. If the assignment's rvalue is used, the value is that assigned to the volatile object. For instance, there is no read of @var{vobj} in all the following cases: @smallexample int obj; volatile int vobj; vobj = @var{something}; obj = vobj = @var{something}; obj ? vobj = @var{onething} : vobj = @var{anotherthing}; obj = (@var{something}, vobj = @var{anotherthing}); @end smallexample If you need to read the volatile object after an assignment has occurred, you must use a separate expression with an intervening sequence point."