public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/64658] New: std::atomic_init() undefined
@ 2015-01-18 17:11 redi at gcc dot gnu.org
  2015-01-18 17:25 ` [Bug libstdc++/64658] " redi at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2015-01-18 17:11 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 64658
           Summary: std::atomic_init() undefined
           Product: gcc
           Version: 4.9.2
            Status: UNCONFIRMED
          Keywords: rejects-valid
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org

#include <atomic>

int main()
{
  std::atomic_int a;
  atomic_init(&a, 0);
}

$ g++ -std=c++11 at.cc
In file included from at.cc:1:0:
/home/jwakely/gcc/5/include/c++/5.0.0/atomic:924:5: warning: inline function
‘void std::atomic_init(std::atomic<_ITp>*, _ITp) [with _ITp = int]’ used but
never defined
     atomic_init(atomic<_ITp>* __a, _ITp __i) noexcept;
     ^
/tmp/ccZgPnay.o: In function `main':
/tmp/at.cc:6: undefined reference to `void
std::atomic_init<int>(std::atomic<int>*, int)'
collect2: error: ld returned 1 exit status
>From gcc-bugs-return-473732-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Sun Jan 18 17:24:22 2015
Return-Path: <gcc-bugs-return-473732-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 10457 invoked by alias); 18 Jan 2015 17:24:04 -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 10278 invoked by uid 48); 18 Jan 2015 17:22:57 -0000
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/64658] std::atomic_init() undefined
Date: Sun, 18 Jan 2015 17:24:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: libstdc++
X-Bugzilla-Version: 4.9.2
X-Bugzilla-Keywords: rejects-valid
X-Bugzilla-Severity: normal
X-Bugzilla-Who: redi 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: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_status cf_reconfirmed_on everconfirmed
Message-ID: <bug-64658-4-0G1E9KUVlx@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-64658-4@http.gcc.gnu.org/bugzilla/>
References: <bug-64658-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: 2015-01/txt/msg01726.txt.bz2
Content-length: 1300

https://gcc.gnu.org/bugzilla/show_bug.cgi?idd658

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2015-01-18
     Ever confirmed|0                           |1

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Although atomic_init doesn't need to be atomic the simplest way to implement it
is just with a relaxed store:

--- a/libstdc++-v3/include/std/atomic
+++ b/libstdc++-v3/include/std/atomic
@@ -921,11 +921,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION

   template<typename _ITp>
     inline void
-    atomic_init(atomic<_ITp>* __a, _ITp __i) noexcept;
+    atomic_init(atomic<_ITp>* __a, _ITp __i) noexcept
+    { __a->store(__i, memory_order_relaxed); }

   template<typename _ITp>
     inline void
-    atomic_init(volatile atomic<_ITp>* __a, _ITp __i) noexcept;
+    atomic_init(volatile atomic<_ITp>* __a, _ITp __i) noexcept
+    { __a->store(__i, memory_order_relaxed); }

   template<typename _ITp>
     inline void


A better implementation would make atomic_init friend of std::atomic so it can
set the private data member directly.


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

end of thread, other threads:[~2015-01-27 20:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-18 17:11 [Bug libstdc++/64658] New: std::atomic_init() undefined redi at gcc dot gnu.org
2015-01-18 17:25 ` [Bug libstdc++/64658] " redi at gcc dot gnu.org
2015-01-20 11:51 ` redi at gcc dot gnu.org
2015-01-27 12:49 ` redi at gcc dot gnu.org
2015-01-27 20:50   ` Jon Chesterfield

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).