From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 8322B3858C54; Tue, 5 Mar 2024 15:38:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8322B3858C54 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1709653115; bh=lcjcNWJ54k1Zf6TxmpHyor8ZmRuAOWwXuy+8Sqz0Owg=; h=From:To:Subject:Date:From; b=qnkhgyX8sXgiv86FuX/aEnMvuZfgAh3D37A8YtpjzkMge6zNNLU3oxkH+CYeHPZ7z IbOLpeJtJuEwCj8dkKt7K2Qbh/ai5rHvdPixFcYH37aGKDFOTNQ3LVSMWP8U9zsuq9 K3I7aFgg3LMyL+kwp3uJvdUuDHdMklmPSOSNjTeY= From: "abbeyj+gcc at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug lto/114241] New: False-positive -Wodr warning when using -flto and -fno-semantic-interposition Date: Tue, 05 Mar 2024 15:38:34 +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.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: abbeyj+gcc 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D114241 Bug ID: 114241 Summary: False-positive -Wodr warning when using -flto and -fno-semantic-interposition Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: lto Assignee: unassigned at gcc dot gnu.org Reporter: abbeyj+gcc at gmail dot com Target Milestone: --- When building the following example, a `-Wodr` warning is shown. I don't t= hink the code violates the ODR so this warning is unexpected. This reproducer consists of 3 files. d.h: ``` class A { public: virtual ~A(); virtual void a1(); }; class B : public A { public: void a1(); virtual void b1() =3D 0; virtual void b2() =3D 0; }; class C : public B { }; class D : public C { public: void b1(); void b2(); }; ``` foo.cpp: ``` #include "d.h" void foo() { D x; } ``` bar.cpp: ``` #include "d.h" void B::a1() { } void bar() { D y; } ``` Build using: g++ -fPIC -fno-semantic-interposition -flto -c foo.cpp g++ -fPIC -fno-semantic-interposition -flto -c bar.cpp g++ -shared foo.o bar.o -o lib.so Output: > d.h:14:7: warning: virtual table of type =E2=80=98struct C=E2=80=99 viola= tes one definition rule [-Wodr] > 14 | class C : public B { > | ^ > d.h:14:7: note: the conflicting type defined in another translation unit = has virtual table with more entries > 14 | class C : public B { > | ^ The warning message here is not great as it refers to "another translation unit" but never names either of the two translation units involved. In this reduced example there are only two translation units but when there are many translation units involved it is more difficult to figure out where the pro= blem is coming from. The bigger issue is that I don't think this warning should have been issued= at all. I can't see any way that the code is violating the ODR. The earliest version that I've been able to reproduce with is 8.4 Godbolt link: https://godbolt.org/z/ncnqPMdzq=