public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/64658] New: std::atomic_init() undefined
Date: Sun, 18 Jan 2015 17:11:00 -0000 [thread overview]
Message-ID: <bug-64658-4@http.gcc.gnu.org/bugzilla/> (raw)
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.
next reply other threads:[~2015-01-18 17:11 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-18 17:11 redi at gcc dot gnu.org [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bug-64658-4@http.gcc.gnu.org/bugzilla/ \
--to=gcc-bugzilla@gcc.gnu.org \
--cc=gcc-bugs@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).