public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/60695] New: std::atomic<X> doesn't work when X is of zero size
@ 2014-03-28 12:54 roman at binarylife dot net
  2014-03-28 13:11 ` [Bug c++/60695] " redi at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: roman at binarylife dot net @ 2014-03-28 12:54 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 60695
           Summary: std::atomic<X> doesn't work when X is of zero size
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: roman at binarylife dot net

$ cat test.cc 
#include <atomic>

struct X {
  char stuff[0];
};

X foo(std::atomic<X>& a, X x) {
  a = x;
  return a;
}

$ g++ -std=c++11 -c test.cc 
In file included from test.cc:1:0:
/home/abend/local/gcc-4.9/include/c++/4.9.0/atomic: In instantiation of ‘void
std::atomic<_Tp>::store(_Tp, std::memory_order) [with _Tp = X;
std::memory_order = std::memory_order]’:
/home/abend/local/gcc-4.9/include/c++/4.9.0/atomic:183:18:   required from ‘_Tp
std::atomic<_Tp>::operator=(_Tp) [with _Tp = X]’
test.cc:8:5:   required from here
/home/abend/local/gcc-4.9/include/c++/4.9.0/atomic:199:39: error: argument 1 of
‘__atomic_store’ must be a pointer to a nonzero size object
       { __atomic_store(&_M_i, &__i, _m); }
                                       ^
/home/abend/local/gcc-4.9/include/c++/4.9.0/atomic: In instantiation of ‘_Tp
std::atomic<_Tp>::load(std::memory_order) const [with _Tp = X;
std::memory_order = std::memory_order]’:
/home/abend/local/gcc-4.9/include/c++/4.9.0/atomic:176:21:   required from
‘std::atomic<_Tp>::operator _Tp() const [with _Tp = X]’
test.cc:9:10:   required from here
/home/abend/local/gcc-4.9/include/c++/4.9.0/atomic:209:31: error: argument 1 of
‘__atomic_load’ must be a pointer to a nonzero size object
  __atomic_load(&_M_i, &tmp, _m); 
                               ^
$ g++ --version
g++ (GCC) 4.9.0 20140327 (experimental)
...
>From gcc-bugs-return-447713-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Fri Mar 28 13:02:19 2014
Return-Path: <gcc-bugs-return-447713-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 26197 invoked by alias); 28 Mar 2014 13:02:19 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 25878 invoked by uid 48); 28 Mar 2014 13:02:14 -0000
From: "burnus at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/60677] [4.9 Regression] FAIL: gfortran.dg/ichar_3.f90  -O  (test for excess errors)
Date: Fri, 28 Mar 2014 13:02:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: fortran
X-Bugzilla-Version: 4.9.0
X-Bugzilla-Keywords: wrong-code
X-Bugzilla-Severity: normal
X-Bugzilla-Who: burnus at gcc dot gnu.org
X-Bugzilla-Status: NEW
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: 4.9.0
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-60677-4-hKTpoDRwKC@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-60677-4@http.gcc.gnu.org/bugzilla/>
References: <bug-60677-4@http.gcc.gnu.org/bugzilla/>
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-03/txt/msg02582.txt.bz2
Content-length: 180

http://gcc.gnu.org/bugzilla/show_bug.cgi?id`677

--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> ---
*** Bug 60678 has been marked as a duplicate of this bug. ***


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

* [Bug c++/60695] std::atomic<X> doesn't work when X is of zero size
  2014-03-28 12:54 [Bug c++/60695] New: std::atomic<X> doesn't work when X is of zero size roman at binarylife dot net
@ 2014-03-28 13:11 ` redi at gcc dot gnu.org
  2014-03-28 13:26 ` [Bug libstdc++/60695] " redi at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2014-03-28 13:11 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
That type isn't valid in ISO C++ and I don't see how you can usefully use it as
an atomic object, so I don't think this failure matters.

My preference would be to add this to std::atomic<_Tp>:

  static_assert( sizeof(_Tp) > 0, "Don't be silly" );


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

* [Bug libstdc++/60695] std::atomic<X> doesn't work when X is of zero size
  2014-03-28 12:54 [Bug c++/60695] New: std::atomic<X> doesn't work when X is of zero size roman at binarylife dot net
  2014-03-28 13:11 ` [Bug c++/60695] " redi at gcc dot gnu.org
@ 2014-03-28 13:26 ` redi at gcc dot gnu.org
  2014-03-28 13:36 ` roman at binarylife dot net
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2014-03-28 13:26 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2014-03-28
          Component|c++                         |libstdc++
           Assignee|unassigned at gcc dot gnu.org      |redi at gcc dot gnu.org
     Ever confirmed|0                           |1
           Severity|normal                      |enhancement

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I'll add that assertion in the library.


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

* [Bug libstdc++/60695] std::atomic<X> doesn't work when X is of zero size
  2014-03-28 12:54 [Bug c++/60695] New: std::atomic<X> doesn't work when X is of zero size roman at binarylife dot net
  2014-03-28 13:11 ` [Bug c++/60695] " redi at gcc dot gnu.org
  2014-03-28 13:26 ` [Bug libstdc++/60695] " redi at gcc dot gnu.org
@ 2014-03-28 13:36 ` roman at binarylife dot net
  2014-03-28 17:27 ` redi at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: roman at binarylife dot net @ 2014-03-28 13:36 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Roman Kononov <roman at binarylife dot net> ---
Yes, it is definitely silly in some sense. But, some templated user code might
become more complex with this behaviour. If gcc supports zero-sized objects it
would be nice to support them fully. The implementation for this case might do
the synchronization part without any data exchange.


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

* [Bug libstdc++/60695] std::atomic<X> doesn't work when X is of zero size
  2014-03-28 12:54 [Bug c++/60695] New: std::atomic<X> doesn't work when X is of zero size roman at binarylife dot net
                   ` (2 preceding siblings ...)
  2014-03-28 13:36 ` roman at binarylife dot net
@ 2014-03-28 17:27 ` redi at gcc dot gnu.org
  2014-04-15 13:48 ` redi at gcc dot gnu.org
  2014-04-15 14:07 ` redi at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2014-03-28 17:27 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I don't buy it. That zero-size struct type has very limited uses, it's not the
sort of type you use like other value types, and I can't imagine any scenario
where that type is useful where you're also storing generic types in
std::atomic.

I don't want to complicate the implementation even if someone thinks of an
obscure hypothetical use case.


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

* [Bug libstdc++/60695] std::atomic<X> doesn't work when X is of zero size
  2014-03-28 12:54 [Bug c++/60695] New: std::atomic<X> doesn't work when X is of zero size roman at binarylife dot net
                   ` (3 preceding siblings ...)
  2014-03-28 17:27 ` redi at gcc dot gnu.org
@ 2014-04-15 13:48 ` redi at gcc dot gnu.org
  2014-04-15 14:07 ` redi at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2014-04-15 13:48 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Author: redi
Date: Tue Apr 15 13:48:07 2014
New Revision: 209418

URL: http://gcc.gnu.org/viewcvs?rev=209418&root=gcc&view=rev
Log:
    PR libstdc++/60695
    * include/std/atomic (atomic<_Tp>): Add static assertion.
    * testsuite/29_atomics/atomic/60695.cc: New.

Added:
    trunk/libstdc++-v3/testsuite/29_atomics/atomic/60695.cc
Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/include/std/atomic


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

* [Bug libstdc++/60695] std::atomic<X> doesn't work when X is of zero size
  2014-03-28 12:54 [Bug c++/60695] New: std::atomic<X> doesn't work when X is of zero size roman at binarylife dot net
                   ` (4 preceding siblings ...)
  2014-04-15 13:48 ` redi at gcc dot gnu.org
@ 2014-04-15 14:07 ` redi at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2014-04-15 14:07 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED
   Target Milestone|---                         |4.10.0

--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
fixed


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

end of thread, other threads:[~2014-04-15 14:07 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-28 12:54 [Bug c++/60695] New: std::atomic<X> doesn't work when X is of zero size roman at binarylife dot net
2014-03-28 13:11 ` [Bug c++/60695] " redi at gcc dot gnu.org
2014-03-28 13:26 ` [Bug libstdc++/60695] " redi at gcc dot gnu.org
2014-03-28 13:36 ` roman at binarylife dot net
2014-03-28 17:27 ` redi at gcc dot gnu.org
2014-04-15 13:48 ` redi at gcc dot gnu.org
2014-04-15 14:07 ` 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).