From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32389 invoked by alias); 6 Feb 2013 15:00:53 -0000 Received: (qmail 31607 invoked by uid 48); 6 Feb 2013 15:00:01 -0000 From: "jason at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/47409] volatile struct member bug Date: Wed, 06 Feb 2013 15:00:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: jason at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2013-02/txt/msg00543.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47409 --- Comment #14 from Jason Merrill 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.