From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11787 invoked by alias); 28 Jan 2015 21:44:33 -0000 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 Received: (qmail 11620 invoked by uid 48); 28 Jan 2015 21:44:28 -0000 From: "richard-gccbugzilla at metafoo dot co.uk" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/64843] miscompilation of atomic_fetch_add on atomic pointer type Date: Wed, 28 Jan 2015 21:44: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-Version: 4.9.0 X-Bugzilla-Keywords: documentation, wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: richard-gccbugzilla at metafoo dot co.uk X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-01/txt/msg03320.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64843 --- Comment #2 from Richard Smith --- libstdc++ uses these builtins in bits/atomic_base.h: __pointer_type fetch_add(ptrdiff_t __d, memory_order __m = memory_order_seq_cst) noexcept { return __atomic_fetch_add(&_M_p, _M_type_size(__d), __m); } Naturally, it's up to you guys how you handle this, but it would be problematic at least for Clang if the semantics of __atomic_fetch_add change to match the documentation: we'd somehow need to detect which flavor of libstdc++ is in use when compiling . There may also be user code that depends on the current semantics that would be broken by changing the de facto semantics (that have been present for many GCC releases). Here's Clang's documentation for its __c11_* builtin set: http://clang.llvm.org/docs/LanguageExtensions.html#c11-atomic-builtins