public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "cfsteefel at arista dot com" <gcc-bugzilla@gcc.gnu.org> 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 [thread overview] Message-ID: <bug-107597-4-TERLZ4aIGO@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-107597-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107597 --- Comment #3 from Christoph Steefel <cfsteefel at arista dot com> --- 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.cpp -fsanitize=address > g++ -shared -o libTest2.so -flto -fsemantic-interposition -fPIC test2.cpp -fsanitize=address > g++ -shared -o libMain.so -flto -fsemantic-interposition -fPIC main.cpp -fsanitize=address > g++ libMain.so libTest1.so libTest2.so -fsanitize=address > LD_LIBRARY_PATH=. ./a.out ================================================================= ==9794==ERROR: AddressSanitizer: odr-violation (0x7f6340a3d0e0): [1] size=4 'x' test.h:2:22 [2] size=4 '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.
next prev parent reply other threads:[~2022-11-14 17:38 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-11-09 19:09 [Bug c++/107597] New: " cfsteefel at arista dot com 2022-11-10 7:31 ` [Bug c++/107597] " rguenth at gcc dot gnu.org 2022-11-11 17:42 ` hubicka at ucw dot cz 2022-11-14 17:38 ` cfsteefel at arista dot com [this message] 2022-11-21 10:12 ` marxin at gcc dot gnu.org 2022-12-28 9:37 ` marxin at gcc dot gnu.org 2022-12-28 9:39 ` marxin at gcc dot gnu.org 2023-01-04 17:28 ` hubicka at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-107597-4-TERLZ4aIGO@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).