From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32170 invoked by alias); 21 Sep 2014 17:24:47 -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 32139 invoked by uid 48); 21 Sep 2014 17:24:41 -0000 From: "roman at binarylife dot net" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/63322] New: std::atomic where T is not trivially copyable should be disabled. Date: Sun, 21 Sep 2014 17:24:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 5.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: roman at binarylife dot net X-Bugzilla-Status: UNCONFIRMED 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter Message-ID: 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: 2014-09/txt/msg02031.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63322 Bug ID: 63322 Summary: std::atomic where T is not trivially copyable should be disabled. Product: gcc Version: 5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: roman at binarylife dot net [atomic.types.generic]: There is a generic class template atomic. The type of the template argument T shall be trivially copyable (3.9). It would be helpful if std::atomic disallowed wrong T because the generated code is obviously makes no sense (at least for x86_64): bar() returns a hard-coded NaN. $ cat test.cc #include long double foo(const long double& f) noexcept; struct X { X() = default; X(X const& o) noexcept : f(foo(o.f)) {} X& operator=(X const& o) noexcept { f = foo(o.f); return *this; } long double f = foo(0); }; extern std::atomic a; long double bar() { a.load().f; } $ g++ -c -O2 --save-temps -std=c++11 test.cc && echo ok ok $ cat test.s .file "test.cc" .section .text.unlikely,"ax",@progbits .LCOLDB2: .text .LHOTB2: .p2align 4,,15 .globl _Z3barv .type _Z3barv, @function _Z3barv: .LFB330: .cfi_startproc fldz subq $24, %rsp .cfi_def_cfa_offset 32 movq %rsp, %rdi fstpt (%rsp) call _Z3fooRKe fstp %st(0) movl $5, %esi movl $a, %edi call __atomic_load_16 flds .LC1(%rip) addq $24, %rsp .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE330: .size _Z3barv, .-_Z3barv .section .text.unlikely .LCOLDE2: .text .LHOTE2: .section .rodata.cst4,"aM",@progbits,4 .align 4 .LC1: .long 2143289344 .ident "GCC: (GNU) 5.0.0 20140920 (experimental)" .section .note.GNU-stack,"",@progbits