public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c++/96445] New: extern template results in missing constructor symbol @ 2020-08-03 19:57 tyu at eridex dot org 2020-08-04 6:03 ` [Bug c++/96445] " rguenth at gcc dot gnu.org 2022-02-18 20:33 ` tyu at eridex dot org 0 siblings, 2 replies; 3+ messages in thread From: tyu at eridex dot org @ 2020-08-03 19:57 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96445 Bug ID: 96445 Summary: extern template results in missing constructor symbol Product: gcc Version: 10.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: tyu at eridex dot org Target Milestone: --- Created attachment 48989 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48989&action=edit g++ -v output The following results in: undefined reference to `C<int>::C(int)' template <typename T> class C { private: constexpr C(T){}; public: constexpr static C<T> make(T t) { return C<T>(t); } }; extern template class C<int>; inline constexpr C<int> constant = C<int>::make(0); template class C<int>; int main() { return 0; } Compiled with: $ g++ -v -save-temps -std=c++2a -Wall -Wextra issue.cpp > output.txt 2>&1 output.txt is attached. ^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/96445] extern template results in missing constructor symbol 2020-08-03 19:57 [Bug c++/96445] New: extern template results in missing constructor symbol tyu at eridex dot org @ 2020-08-04 6:03 ` rguenth at gcc dot gnu.org 2022-02-18 20:33 ` tyu at eridex dot org 1 sibling, 0 replies; 3+ messages in thread From: rguenth at gcc dot gnu.org @ 2020-08-04 6:03 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96445 Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |link-failure CC| |jason at gcc dot gnu.org --- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> --- extern template class C<int>; template class C<int>; combo probably does not instanitate C<int>. ^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/96445] extern template results in missing constructor symbol 2020-08-03 19:57 [Bug c++/96445] New: extern template results in missing constructor symbol tyu at eridex dot org 2020-08-04 6:03 ` [Bug c++/96445] " rguenth at gcc dot gnu.org @ 2022-02-18 20:33 ` tyu at eridex dot org 1 sibling, 0 replies; 3+ messages in thread From: tyu at eridex dot org @ 2022-02-18 20:33 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96445 --- Comment #2 from tyu at eridex dot org --- The extern template and constant are what would appear in the header file for class C. The explicit instantiation would appear in the source file: // -- C.h ------------ template <typename T> class C { private: constexpr C(T){}; public: constexpr static C<T> make(T t) { return C<T>(t); } }; extern template class C<int>; inline constexpr C<int> constant = C<int>::make(0); // -- C.cpp ---------- template class C<int>; // -- main.cpp ------- int main() { return 0; } // ------------------- ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-02-18 20:33 UTC | newest] Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2020-08-03 19:57 [Bug c++/96445] New: extern template results in missing constructor symbol tyu at eridex dot org 2020-08-04 6:03 ` [Bug c++/96445] " rguenth at gcc dot gnu.org 2022-02-18 20:33 ` tyu at eridex dot 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).