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.

Reply via email to