public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/67632] New: explicit instantiation omits copy constructor and others
@ 2015-09-18 20:54 jlink at drw dot com
2015-09-18 22:04 ` [Bug c++/67632] " trippels at gcc dot gnu.org
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: jlink at drw dot com @ 2015-09-18 20:54 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67632
Bug ID: 67632
Summary: explicit instantiation omits copy constructor and
others
Product: gcc
Version: 4.9.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: jlink at drw dot com
Target Milestone: ---
When I compile the follow test case with g++ -std=c++11 -c, and view the output
with nm, it shows that the std::unordered_map copy constructor is never
emitted:
% cat t.cc
#include <unordered_map>
template class std::unordered_map<int, int>;
% g++ -std=c++11 -c t.cc
%
If I compile the following and link it with the above, I'll get the undefined
reference:
% cat x.cc
#include <unordered_map>
extern template class std::unordered_map<int, int>;
std::unordered_map<int, int> copy(
const std::unordered_map<int, int> & a) { return a; }
main() {}
% g++ -std=c++11 t.o x.cc
/tmp/cc0dF94P.o: In function `copy(std::unordered_map<int, int, std::hash<int>,
std::equal_to<int>, std::allocator<std::pair<int const, int> > > const&)':
x.cc:(.text+0x1f): undefined reference to `std::unordered_map<int, int,
std::hash<int>, std::equal_to<int>, std::allocator<std::pair<int const, int> >
>::unordered_map(std::unordered_map<int, int, std::hash<int>,
std::equal_to<int>, std::allocator<std::pair<int const, int> > > const&)'
collect2: error: ld returned 1 exit status
This seems like a clear bug, right? Either the explicit instantiation should
emit everything, or the use of extern template should know what still needs to
be emitted locally.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/67632] explicit instantiation omits copy constructor and others
2015-09-18 20:54 [Bug c++/67632] New: explicit instantiation omits copy constructor and others jlink at drw dot com
@ 2015-09-18 22:04 ` trippels at gcc dot gnu.org
2015-09-18 22:44 ` jlink at drw dot com
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: trippels at gcc dot gnu.org @ 2015-09-18 22:04 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67632
Markus Trippelsdorf <trippels at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |UNCONFIRMED
Resolution|WORKSFORME |---
--- Comment #2 from Markus Trippelsdorf <trippels at gcc dot gnu.org> ---
Reopened. I've tested for the wrong symbol.
I let others handle this.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/67632] explicit instantiation omits copy constructor and others
2015-09-18 20:54 [Bug c++/67632] New: explicit instantiation omits copy constructor and others jlink at drw dot com
2015-09-18 22:04 ` [Bug c++/67632] " trippels at gcc dot gnu.org
@ 2015-09-18 22:44 ` jlink at drw dot com
2015-09-19 9:20 ` [Bug libstdc++/67632] " trippels at gcc dot gnu.org
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: jlink at drw dot com @ 2015-09-18 22:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67632
--- Comment #3 from Joseph Link <jlink at drw dot com> ---
Yeah, watch out for the copy constructor that takes an allocator. That one's
there. The compiler generated one is not.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug libstdc++/67632] explicit instantiation omits copy constructor and others
2015-09-18 20:54 [Bug c++/67632] New: explicit instantiation omits copy constructor and others jlink at drw dot com
2015-09-18 22:04 ` [Bug c++/67632] " trippels at gcc dot gnu.org
2015-09-18 22:44 ` jlink at drw dot com
@ 2015-09-19 9:20 ` trippels at gcc dot gnu.org
2015-09-19 10:20 ` redi at gcc dot gnu.org
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: trippels at gcc dot gnu.org @ 2015-09-19 9:20 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67632
Markus Trippelsdorf <trippels at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |redi at gcc dot gnu.org
Component|c++ |libstdc++
--- Comment #4 from Markus Trippelsdorf <trippels at gcc dot gnu.org> ---
Might be a libstdc++ issue. Adding CC.
markus@x4 /tmp % g++ -c -O0 -std=c++11 t.cpp
markus@x4 /tmp % nm t.o | grep
_ZNSt13unordered_mapIiiSt4hashIiESt8equal_toIiESaISt4pairIKiiEEEC1ERKS8_
0000000000000000 W
_ZNSt13unordered_mapIiiSt4hashIiESt8equal_toIiESaISt4pairIKiiEEEC1ERKS8_RKS7_
markus@x4 /tmp % g++ -Wl,--no-demangle -O0 -std=c++11 t.cpp x.cpp
/tmp/ccMHoCTz.o:x.cpp:function
_Z4copyRKSt13unordered_mapIiiSt4hashIiESt8equal_toIiESaISt4pairIKiiEEE: error:
undefined reference to
'_ZNSt13unordered_mapIiiSt4hashIiESt8equal_toIiESaISt4pairIKiiEEEC1ERKS8_'
collect2: error: ld returned 1 exit status
markus@x4 /tmp % c++filt
_ZNSt13unordered_mapIiiSt4hashIiESt8equal_toIiESaISt4pairIKiiEEEC1ERKS8_
std::unordered_map<int, int, std::hash<int>, std::equal_to<int>,
std::allocator<std::pair<int const, int> >
>::unordered_map(std::unordered_map<int, int, std::hash<int>,
std::equal_to<int>, std::allocator<std::pair<int const, int> > > const&)
markus@x4 /tmp % c++filt
_ZNSt13unordered_mapIiiSt4hashIiESt8equal_toIiESaISt4pairIKiiEEEC1ERKS8_RKS7_
std::unordered_map<int, int, std::hash<int>, std::equal_to<int>,
std::allocator<std::pair<int const, int> >
>::unordered_map(std::unordered_map<int, int, std::hash<int>,
std::equal_to<int>, std::allocator<std::pair<int const, int> > > const&,
std::allocator<std::pair<int const, int> > const&)
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug libstdc++/67632] explicit instantiation omits copy constructor and others
2015-09-18 20:54 [Bug c++/67632] New: explicit instantiation omits copy constructor and others jlink at drw dot com
` (2 preceding siblings ...)
2015-09-19 9:20 ` [Bug libstdc++/67632] " trippels at gcc dot gnu.org
@ 2015-09-19 10:20 ` redi at gcc dot gnu.org
2015-09-19 10:24 ` trippels at gcc dot gnu.org
2015-09-19 10:31 ` redi at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2015-09-19 10:20 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67632
--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Not sure how it can be a libstdc++ issue, the copy constructor exists, the
library can't force the front-end to instantiate it.
I'm travelling without access to proper computers, but as far as I can tell
from coliru.stacked-crooked.com it links fine using clang++ -stdlib=libstdc++
(with libstdc++ 5.2.0).
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug libstdc++/67632] explicit instantiation omits copy constructor and others
2015-09-18 20:54 [Bug c++/67632] New: explicit instantiation omits copy constructor and others jlink at drw dot com
` (3 preceding siblings ...)
2015-09-19 10:20 ` redi at gcc dot gnu.org
@ 2015-09-19 10:24 ` trippels at gcc dot gnu.org
2015-09-19 10:31 ` redi at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: trippels at gcc dot gnu.org @ 2015-09-19 10:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67632
--- Comment #6 from Markus Trippelsdorf <trippels at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #5)
> Not sure how it can be a libstdc++ issue, the copy constructor exists, the
> library can't force the front-end to instantiate it.
>
> I'm travelling without access to proper computers, but as far as I can tell
> from coliru.stacked-crooked.com it links fine using clang++
> -stdlib=libstdc++ (with libstdc++ 5.2.0).
No, it doesn't for -O0. Higher -O values make the issue go away.
markus@x4 /tmp % clang++ -stdlib=libc++ -O0 -std=c++11 t.cpp x.cpp
markus@x4 /tmp % clang++ -Wl,--no-demangle -O0 -std=c++11 t.cpp x.cpp
/tmp/x-5ef538.o:x.cpp:function
_Z4copyRKSt13unordered_mapIiiSt4hashIiESt8equal_toIiESaISt4pairIKiiEEE: error:
undefined reference to
'_ZNSt13unordered_mapIiiSt4hashIiESt8equal_toIiESaISt4pairIKiiEEEC1ERKS8_'
clang-3.8: error: linker command failed with exit code 1 (use -v to see
invocation)
markus@x4 /tmp % icpc -Wl,--no-demangle -O0 -std=c++11 t.cpp x.cpp
/tmp/icpcMamJXz.o:x.cpp:function
_Z4copyRKSt13unordered_mapIiiSt4hashIiESt8equal_toIiESaISt4pairIKiiEEE: error:
undefined reference to
'_ZNSt13unordered_mapIiiSt4hashIiESt8equal_toIiESaISt4pairIKiiEEEC1ERKS8_'
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug libstdc++/67632] explicit instantiation omits copy constructor and others
2015-09-18 20:54 [Bug c++/67632] New: explicit instantiation omits copy constructor and others jlink at drw dot com
` (4 preceding siblings ...)
2015-09-19 10:24 ` trippels at gcc dot gnu.org
@ 2015-09-19 10:31 ` redi at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2015-09-19 10:31 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67632
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2015-09-19
Ever confirmed|0 |1
--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Markus Trippelsdorf from comment #6)
> No, it doesn't for -O0. Higher -O values make the issue go away.
Oh, ok, weird. I probably won't be able to look into this further until Monday.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2015-09-19 10:31 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-18 20:54 [Bug c++/67632] New: explicit instantiation omits copy constructor and others jlink at drw dot com
2015-09-18 22:04 ` [Bug c++/67632] " trippels at gcc dot gnu.org
2015-09-18 22:44 ` jlink at drw dot com
2015-09-19 9:20 ` [Bug libstdc++/67632] " trippels at gcc dot gnu.org
2015-09-19 10:20 ` redi at gcc dot gnu.org
2015-09-19 10:24 ` trippels at gcc dot gnu.org
2015-09-19 10:31 ` 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).