https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89856

--- Comment #2 from Daniel Vollmer <zerolo at gmail dot com> ---
I'm seeing the same warning in a similar context when using the
address-sanitizer, e.g.

> cat lib.cpp
#include <string>
#include <iostream>

inline const std::string &func1()
{
  static const std::string str = "abc";
  return str;
}

void func2()
{
  const auto str = func1();
  std::cout << str << std::endl;
}

> g++-7 -fsanitize=address -std=c++14 -shared lib.cpp -o lib.dylib
ld: warning: direct access in function '__GLOBAL__sub_D_00099_0_lib.cpp' from
file '/var/folders/02/yl3m8d4d0397mk6dxn6dpcqw0000gp/T//ccEl2k3C.o' to global
weak symbol 'guard variable for func1[abi:cxx11]()::str' from file
'/var/folders/02/yl3m8d4d0397mk6dxn6dpcqw0000gp/T//ccEl2k3C.o' means the weak
symbol cannot be overridden at runtime. This was likely caused by different
translation units being compiled with different visibility settings.
ld: warning: direct access in function '__GLOBAL__sub_I_00099_1_lib.cpp' from
file '/var/folders/02/yl3m8d4d0397mk6dxn6dpcqw0000gp/T//ccEl2k3C.o' to global
weak symbol 'guard variable for func1[abi:cxx11]()::str' from file
'/var/folders/02/yl3m8d4d0397mk6dxn6dpcqw0000gp/T//ccEl2k3C.o' means the weak
symbol cannot be overridden at runtime. This was likely caused by different
translation units being compiled with different visibility settings.


(Same with g++-9.1)

Reply via email to