public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/63322] New: std::atomic<T> where T is not trivially copyable should be disabled.
@ 2014-09-21 17:24 roman at binarylife dot net
  2014-09-21 18:13 ` [Bug libstdc++/63322] " redi at gcc dot gnu.org
  2014-10-09 18:41 ` redi at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: roman at binarylife dot net @ 2014-09-21 17:24 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63322

            Bug ID: 63322
           Summary: std::atomic<T> 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<T>. The type
of the template argument T shall be trivially copyable (3.9).

It would be helpful if std::atomic<T> 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 <atomic>

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<X> 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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug libstdc++/63322] std::atomic<T> where T is not trivially copyable should be disabled.
  2014-09-21 17:24 [Bug libstdc++/63322] New: std::atomic<T> where T is not trivially copyable should be disabled roman at binarylife dot net
@ 2014-09-21 18:13 ` redi at gcc dot gnu.org
  2014-10-09 18:41 ` redi at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: redi at gcc dot gnu.org @ 2014-09-21 18:13 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63322

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
This is hard to enforce because we don't support std::is_trivially_copyable.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug libstdc++/63322] std::atomic<T> where T is not trivially copyable should be disabled.
  2014-09-21 17:24 [Bug libstdc++/63322] New: std::atomic<T> where T is not trivially copyable should be disabled roman at binarylife dot net
  2014-09-21 18:13 ` [Bug libstdc++/63322] " redi at gcc dot gnu.org
@ 2014-10-09 18:41 ` redi at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: redi at gcc dot gnu.org @ 2014-10-09 18:41 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63322

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |FIXED
   Target Milestone|---                         |5.0

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Fixed for 5.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-10-09 18:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-21 17:24 [Bug libstdc++/63322] New: std::atomic<T> where T is not trivially copyable should be disabled roman at binarylife dot net
2014-09-21 18:13 ` [Bug libstdc++/63322] " redi at gcc dot gnu.org
2014-10-09 18:41 ` redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).