public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/94960] New: extern template prevents inlining of standard library objects
@ 2020-05-05 20:09 krzysio.kurek at wp dot pl
  2020-05-05 21:02 ` [Bug libstdc++/94960] " pinskia at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: krzysio.kurek at wp dot pl @ 2020-05-05 20:09 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94960

            Bug ID: 94960
           Summary: extern template prevents inlining of standard library
                    objects
           Product: gcc
           Version: 9.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: krzysio.kurek at wp dot pl
  Target Milestone: ---

Consider this example
void foo()
{
  std::string(1, 0);
}
(https://godbolt.org/z/AlkBBJ)
This function creates a string using the `basic_string(size_t, CharT)`
constructor and then discards it. This particular constructor uses _M_construct
internally, which is declared as an out of line member function. Because of
this, and because the function isn't marked as `inline`, when the compiler
reaches the `extern template class basic_string<char>;`, it foregoes trying to
find the definition for _M_construct, instead generating a call to it, causing
foo() to fully instantiate a string object and then delete it, since the
compiler can't find _M_construct within its own translation unit.

This problem applies to every member function of any class which has an extern
template, is defined out of line and is not marked as `inline`.

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-02-18  0:53 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-05 20:09 [Bug libstdc++/94960] New: extern template prevents inlining of standard library objects krzysio.kurek at wp dot pl
2020-05-05 21:02 ` [Bug libstdc++/94960] " pinskia at gcc dot gnu.org
2020-05-05 21:08 ` redi at gcc dot gnu.org
2020-05-06  0:19 ` erich.keane at intel dot com
2020-05-06  7:05 ` [Bug c++/94960] " rguenth at gcc dot gnu.org
2020-05-06  9:11 ` redi at gcc dot gnu.org
2020-05-06 13:01 ` erich.keane at intel dot com
2022-02-17 17:01 ` jason at gcc dot gnu.org
2022-02-17 23:54 ` redi at gcc dot gnu.org
2022-02-18  0:53 ` erich.keane at intel 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).