public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/63876] New: static data members of template classes w/ default ctors gives "undefined reference" error
@ 2014-11-14 18:01 aleaverfay at gmail dot com
2014-11-14 18:41 ` [Bug c++/63876] " redi at gcc dot gnu.org
2014-11-14 19:33 ` aleaverfay at gmail dot com
0 siblings, 2 replies; 3+ messages in thread
From: aleaverfay at gmail dot com @ 2014-11-14 18:01 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63876
Bug ID: 63876
Summary: static data members of template classes w/ default
ctors gives "undefined reference" error
Product: gcc
Version: 4.8.2
Status: UNCONFIRMED
Severity: major
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: aleaverfay at gmail dot com
Created attachment 33973
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=33973&action=edit
.cc, .hh, and .ii files along with the compilation command
Static data members of template classes that use default constructors don't
seem to get symbols emitted for them.
I have a case where I cannot use anything besides the default constructor for
this static data member: std::mutex.
I've created a small test case that gives me the same problem.
gcc version: 4.8.2 (Ubuntu 4.8.2-19ubuntu1)
system type: Ubuntu 14.04.1
(I don't know what options were given to g++ when it was built; how do I find
that out?)
command line: (also in attachment)
g++ -std=c++0x main.cc test.cc -I.
compiler output:
/tmp/cci1VgZe.o: In function `Foo::set_bar(int)':
test.cc:(.text+0x86): undefined reference to `CRTP_class<Foo>::mutex_'
collect2: error: ld returned 1 exit status
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/63876] static data members of template classes w/ default ctors gives "undefined reference" error
2014-11-14 18:01 [Bug c++/63876] New: static data members of template classes w/ default ctors gives "undefined reference" error aleaverfay at gmail dot com
@ 2014-11-14 18:41 ` redi at gcc dot gnu.org
2014-11-14 19:33 ` aleaverfay at gmail dot com
1 sibling, 0 replies; 3+ messages in thread
From: redi at gcc dot gnu.org @ 2014-11-14 18:41 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63876
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |INVALID
Severity|major |normal
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
You've only declared a specialization, this is not a definition:
template<> std::mutex CRTP_class< Foo >::mutex_;
You can make it a definition with an initializer:
template<> std::mutex CRTP_class< Foo >::mutex_{};
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/63876] static data members of template classes w/ default ctors gives "undefined reference" error
2014-11-14 18:01 [Bug c++/63876] New: static data members of template classes w/ default ctors gives "undefined reference" error aleaverfay at gmail dot com
2014-11-14 18:41 ` [Bug c++/63876] " redi at gcc dot gnu.org
@ 2014-11-14 19:33 ` aleaverfay at gmail dot com
1 sibling, 0 replies; 3+ messages in thread
From: aleaverfay at gmail dot com @ 2014-11-14 19:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63876
--- Comment #2 from Andrew Leaver-Fay <aleaverfay at gmail dot com> ---
Thank you!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-11-14 19:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-14 18:01 [Bug c++/63876] New: static data members of template classes w/ default ctors gives "undefined reference" error aleaverfay at gmail dot com
2014-11-14 18:41 ` [Bug c++/63876] " redi at gcc dot gnu.org
2014-11-14 19:33 ` aleaverfay at gmail dot com
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).