public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/65756] New: undefined reference to __atomic_store for odd-sized std::atomic<T>
@ 2015-04-13 23:31 msebor at gcc dot gnu.org
2015-04-13 23:32 ` [Bug libstdc++/65756] " redi at gcc dot gnu.org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: msebor at gcc dot gnu.org @ 2015-04-13 23:31 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65756
Bug ID: 65756
Summary: undefined reference to __atomic_store for odd-sized
std::atomic<T>
Product: gcc
Version: 5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: msebor at gcc dot gnu.org
The following C++ 11 program fails to link with GCC (both 4.9 and 5.0) because
the primary std::atomic template allocates 3 bytes for both a and aa and calls
__atomic_store(&aa.a, &tmp, __ATOMIC_SEQ_CST). GCC only supports calls to
__atomic_store with power of 2 arguments of at most 8. Assuming the code is
well-defined (I couldn't find anything to suggest otherwise -- the type meets
the trivially-copyable requirement) it seems that specializations of the
template on types of such sizes should add padding up to the nearest greater
power of 2 and increase their own alignment so as to make it possible to
manipulate them atomically. Larger specializations will need to make use of a
mutex.
$ cat a.cpp && g++ -Wall -Wpedantic -std=c++11 a.cpp
#include <atomic>
int main (void) {
struct A { char a [3]; } a = { { 'a', 'b', 'c' } };
std::atomic<A> aa;
aa.store (a);
}
/tmp/ccGQyZte.o: In function `std::atomic<main::A>::store(main::A,
std::memory_order)':
a.cpp:(.text+0xf0): undefined reference to `__atomic_store'
collect2: error: ld returned 1 exit status
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug libstdc++/65756] undefined reference to __atomic_store for odd-sized std::atomic<T>
2015-04-13 23:31 [Bug libstdc++/65756] New: undefined reference to __atomic_store for odd-sized std::atomic<T> msebor at gcc dot gnu.org
@ 2015-04-13 23:32 ` redi at gcc dot gnu.org
2015-04-14 0:20 ` msebor at gcc dot gnu.org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2015-04-13 23:32 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65756
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
You need to link to libatomic for objects with sizes that aren't supported
natively by the CPU.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug libstdc++/65756] undefined reference to __atomic_store for odd-sized std::atomic<T>
2015-04-13 23:31 [Bug libstdc++/65756] New: undefined reference to __atomic_store for odd-sized std::atomic<T> msebor at gcc dot gnu.org
2015-04-13 23:32 ` [Bug libstdc++/65756] " redi at gcc dot gnu.org
@ 2015-04-14 0:20 ` msebor at gcc dot gnu.org
2015-04-14 3:41 ` msebor at gcc dot gnu.org
2015-04-14 7:52 ` jakub at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: msebor at gcc dot gnu.org @ 2015-04-14 0:20 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65756
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |INVALID
--- Comment #2 from Martin Sebor <msebor at gcc dot gnu.org> ---
I see. Thanks. With that fixed, the program links successfully. It would be
nice if GCC gave a better message for this sort of a user error. I recall a
compiler (HP aCC maybe, or MSVC) that suggested a library to link with when the
linker failed with an unsatisfied reference.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug libstdc++/65756] undefined reference to __atomic_store for odd-sized std::atomic<T>
2015-04-13 23:31 [Bug libstdc++/65756] New: undefined reference to __atomic_store for odd-sized std::atomic<T> msebor at gcc dot gnu.org
2015-04-13 23:32 ` [Bug libstdc++/65756] " redi at gcc dot gnu.org
2015-04-14 0:20 ` msebor at gcc dot gnu.org
@ 2015-04-14 3:41 ` msebor at gcc dot gnu.org
2015-04-14 7:52 ` jakub at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: msebor at gcc dot gnu.org @ 2015-04-14 3:41 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65756
--- Comment #3 from Martin Sebor <msebor at gcc dot gnu.org> ---
Interesting. For some programs and libraries, GCC too gives a diagnostic
that's more helpful than just: undefined reference to `foo'
/usr/bin/ld: /tmp/cccCqEak.o: undefined reference to symbol
'pthread_create@@GLIBC_2.2.5'
/lib64/libpthread.so.0: error adding symbols: DSO missing from command line
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug libstdc++/65756] undefined reference to __atomic_store for odd-sized std::atomic<T>
2015-04-13 23:31 [Bug libstdc++/65756] New: undefined reference to __atomic_store for odd-sized std::atomic<T> msebor at gcc dot gnu.org
` (2 preceding siblings ...)
2015-04-14 3:41 ` msebor at gcc dot gnu.org
@ 2015-04-14 7:52 ` jakub at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: jakub at gcc dot gnu.org @ 2015-04-14 7:52 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65756
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
That is only for libraries visible to the linker indirectly (dependencies of
other libraries).
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-04-14 7:52 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-13 23:31 [Bug libstdc++/65756] New: undefined reference to __atomic_store for odd-sized std::atomic<T> msebor at gcc dot gnu.org
2015-04-13 23:32 ` [Bug libstdc++/65756] " redi at gcc dot gnu.org
2015-04-14 0:20 ` msebor at gcc dot gnu.org
2015-04-14 3:41 ` msebor at gcc dot gnu.org
2015-04-14 7:52 ` jakub 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).