From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 3772D388F05C; Tue, 5 May 2020 20:09:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3772D388F05C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1588709398; bh=0QdnYc072WA/3F4hlH9eSSrXoWkxvAbn6r5qTthPg04=; h=From:To:Subject:Date:From; b=d47RQ0XBYOUQyn6lz5eLBEJS5oBkXczsZNRvlRwTPAbBtFgNGKfdHi3gb+f0D/TEK bTjIS4xXasMY6j72bD3/RO2EHs252HVyGUcLOiCX58hECdp3lg4pajP82RRkNa1tX/ qfUFIR7svQ0mWQs7doA4N4VI86b35zlWrmfmIfec= From: "krzysio.kurek at wp dot pl" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/94960] New: extern template prevents inlining of standard library objects Date: Tue, 05 May 2020 20:09:58 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 9.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: krzysio.kurek at wp dot pl X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 May 2020 20:09:58 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94960 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_const= ruct 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;`, it foregoes trying= to find the definition for _M_construct, instead generating a call to it, caus= ing 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 ext= ern template, is defined out of line and is not marked as `inline`.=