From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B3A983860C30; Tue, 2 Feb 2021 09:55:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B3A983860C30 From: "matthieum.147192 at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/98930] New: ICE when using function local static constexpr variable at runtime Date: Tue, 02 Feb 2021 09:55:38 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: matthieum.147192 at gmail dot com 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, 02 Feb 2021 09:55:38 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D98930 Bug ID: 98930 Summary: ICE when using function local static constexpr variable at runtime Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: matthieum.147192 at gmail dot com Target Milestone: --- The following code crashes gcc trunk (11.0) and produces a linker error on prior versions -- from 7.2 to 10.2.1 -- from -O0 to -O3. Link to compiler explorer: https://godbolt.org/z/qox73Y Self-sufficient code snippet: template class Source { public: explicit Source() noexcept { asm volatile("" : : "r,m"(format) : "memory"); } int index() const noexcept { return 0; } }; template T impl() { static constexpr const char FORMAT_[] =3D "Hello, {}!"; static Source const SOURCE{}; return SOURCE.index(); } int main() { return impl(); } GCC trunk crash: : In instantiation of 'Source::Source() [with const char* format =3D (& FORMAT_)]': :4:14: required from here :4:14: internal compiler error: in discriminator_for_local_entity, = at cp/mangle.c:1949 4 | explicit Source() noexcept { | ^~~~~~ 0x1ce5ce9 internal_error(char const*, ...) ???:0 0x6b6f1b fancy_abort(char const*, int, char const*) ???:0 0x812f3b mangle_decl(tree_node*) ???:0 0x135b052 decl_assembler_name(tree_node*) ???:0 0x138e478 assign_assembler_name_if_needed(tree_node*) ???:0 0xb48015 cgraph_node::analyze() ???:0 0xb4c6dd symbol_table::finalize_compilation_unit() ???:0 GCC 10.2 linker error: /opt/compiler-explorer/gcc-10.2.0/bin/../lib/gcc/x86_64-linux-gnu/10.2.0/..= /../../../x86_64-linux-gnu/bin/ld: /tmp/cc6YCcxH.o: in function `_ZN6SourceIXadL_ZZ4implIT_ES1_vE7FORMAT_EEEC1= Ev': /home/ce/:5: undefined reference to `_ZZ4implIT_ES0_vE7FORMAT_' collect2: error: ld returned 1 exit status Other compilers: ICE on Clang 11.0, Works on Clang (trunk). In the same area (local static constexpr) I found 2 bug reports: - https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D95686 - https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D98288 (which I reported) Regards.=