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



--- Comment #14 from Jason Merrill <jason at gcc dot gnu.org> 2013-02-06 
14:59:57 UTC ---

(In reply to comment #13)

> But, what to do about unions?  The standard says that only one union member is

> active, but which one it is?  I think the compiler generally can't know.  So,

> do we just ignore unions and expand them always as we used to?  Pick up the

> first union member (or randomly or preferably one with volatile)?



C++ defines copy of a (trivially copyable) union to copy the object

representation, which is not volatile unless the whole union is volatile.  I

can't find anything relevant in C11.



There is also C++ DR 496:

http://www.open-std.org/JTC1/SC22/WG21/docs/cwg_toc.html#496



It seems the effect of this change will be to make assignment of a union with a

volatile field ill-formed in C++ unless the union has a user-provided

assignment operator.



I think we just ignore unions, at least in the middle end.



> What about bitfields?  Does it have to be per bitfield assignment, or can we

> e.g. assign the whole representative field at a time?



I think we should follow the memory model data race rules here; volatile

accesses are done per memory location, rather than per field.

Reply via email to