From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 099963858C66; Wed, 5 Jun 2024 14:46:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 099963858C66 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1717598770; bh=uQgWHTADTNWITMuAQsIU/i/T7VO0/OQoyelDi1XlQsI=; h=From:To:Subject:Date:From; b=agGepd1DSAtQhMMHmj5Nh3n5IHSTLQKaRXnlZKkBUsyFS2zBWA8BeIWsQfLyX47g8 C6zH1OzlbJYQMwUkkBF4unE8FcASC5W6CcjhWFd5W9z5DhChka1T/HQBVB74xf++aM dSX9iLPWHsWi+g2ergTE0CoCBbcKCdZTCSBbynVQ= From: "a.horodniceanu at proton dot me" To: gcc-bugs@gcc.gnu.org Subject: [Bug lto/115359] New: ICE in warn_types_mismatch: lto1: internal compiler error: Segmentation fault Date: Wed, 05 Jun 2024 14:46:09 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: lto X-Bugzilla-Version: 14.1.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: a.horodniceanu at proton dot me 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D115359 Bug ID: 115359 Summary: ICE in warn_types_mismatch: lto1: internal compiler error: Segmentation fault Product: gcc Version: 14.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: lto Assignee: unassigned at gcc dot gnu.org Reporter: a.horodniceanu at proton dot me Target Milestone: --- Given the two source files: a.cpp: ----- struct Foo { }; void bar(Foo foo); int main() { bar({}); } ---- a.d: ---- extern(C++): struct Foo { } void bar(Foo foo) { } ---- Compile them with: `g++ a.d a.cpp -flto -freport-bug`: ---- a.cpp:2:6: warning: =E2=80=98bar=E2=80=99 violates the C++ One Definition R= ule [-Wodr] 2 | void bar(Foo foo); | ^ a.d:3:6: note: type mismatch in parameter 1 3 | void bar(Foo foo) { } | ^ lto1: internal compiler error: Segmentation fault 0x5654dba30e94 internal_error(char const*, ...) ???:0 0x5654dbaccbd1 xstrdup ???:0 0x5654da59f465 warn_types_mismatch(tree_node*, tree_node*, unsigned int, unsigned int) ???:0 0x5654da30d1e1 lto_symtab_merge_decls() ???:0 0x5654da3154a2 read_cgraph_and_symbols(unsigned int, char const**) ???:0 0x5654da2fdce6 lto_main() ???:0 Please submit a full bug report, with preprocessed source. Please include the complete backtrace with any bug report. See for instructions. lto-wrapper: fatal error: g++ returned 1 exit status compilation terminated. /usr/lib/gcc/x86_64-pc-linux-gnu/14/../../../../x86_64-pc-linux-gnu/bin/ld: error: lto-wrapper failed collect2: error: ld returned 1 exit status ---- g++ --version: ---- g++ (Gentoo Hardened 14.1.1_p20240518 p1) 14.1.1 20240516 Copyright (C) 2024 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ---- I think this can be fixed with: ---- diff --git a/gcc/ipa-devirt.cc b/gcc/ipa-devirt.cc index a7ce434bf..efeb3766c 100644 --- a/gcc/ipa-devirt.cc +++ b/gcc/ipa-devirt.cc @@ -1084,7 +1084,9 @@ warn_types_mismatch (tree t1, tree t2, location_t loc= 1, location_t loc2) if (odr1 !=3D NULL && odr2 !=3D NULL && odr1 !=3D odr2) { const int opts =3D DMGL_PARAMS | DMGL_ANSI | DMGL_TYPES; - char *name1 =3D xstrdup (cplus_demangle (odr1, opts)); + char *name1 =3D cplus_demangle (odr1, opts); + if (name1) + name1 =3D xstrdup(name1); char *name2 =3D cplus_demangle (odr2, opts); if (name1 && name2 && strcmp (name1, name2)) { ---- but I'm not sure if cplus_demangle failing to demangle the D symbol is the = real problem.=