From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id CD1DD3858416; Mon, 14 Nov 2022 17:38:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CD1DD3858416 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1668447515; bh=0W8kyopZ1z8GnEQoz5+58prk5NZOVcz+uhGZYlj6HxY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=eiWXiVZzeNtZIH+oVFIjDofSFeZcHVlRt/8r4QBtdYti1Jwo85/UVs8dIgJC3NYr4 EQ9jR4a3BxDp4PegYyN+MKTMxPaaik3+d+Cep3xTEikuuT1/vYtNVcu8EU3c9ACGJw ugs+jfnNGw9kYCpr3IZ2Me3wjfqttC5KkVdVguvQ= From: "cfsteefel at arista dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/107597] LTO causes static inline variables to get a non-uniqued global symbol Date: Mon, 14 Nov 2022 17:38:35 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 11.3.1 X-Bugzilla-Keywords: lto, wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: cfsteefel at arista dot com X-Bugzilla-Status: NEW 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: Message-ID: In-Reply-To: References: 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=3D107597 --- Comment #3 from Christoph Steefel --- Address sanitizer is the one that flags it. This is the code I used to reproduce the failure. test.h: class NonTemplated { static inline int x; public: void doFoo() { x++; } }; int foo(); int bar(); test1.cpp: #include "test.h" int foo() { NonTemplated n; n.doFoo(); return 1; } test2.cpp: #include "test.h" int bar() { NonTemplated n; n.doFoo(); return 1; } main.cpp: #include "test.h" int main(){ foo(); bar(); return 0; } > g++ -shared -o libTest1.so -flto -fsemantic-interposition -fPIC test1.cp= p -fsanitize=3Daddress > g++ -shared -o libTest2.so -flto -fsemantic-interposition -fPIC test2.cpp= -fsanitize=3Daddress > g++ -shared -o libMain.so -flto -fsemantic-interposition -fPIC main.cpp -= fsanitize=3Daddress > g++ libMain.so libTest1.so libTest2.so -fsanitize=3Daddress > LD_LIBRARY_PATH=3D. ./a.out =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D9794=3D=3DERROR: AddressSanitizer: odr-violation (0x7f6340a3d0e0): [1] size=3D4 'x' test.h:2:22 [2] size=3D4 'x' test.h:2:22 ... (backtrace elided) My general understanding is that address sanitizer doesn't instrument weak = or unique symbols, but will clearly instrument the non-weak symbol here.=