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

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
The following should run and exit successfully:

$ cat lib.h
template<typename T>
struct A {
  static T member;
};
template<typename T>
  T A<T>::member;

bool match(int*);

$ cat lib.cc
#include "lib.h"

template class A<int>;

bool match(int* p)
{
  return p == &A<int>::member;
}

$ cat main.cc
#include "lib.h"

int main()
{
  if (!match(&A<int>::member))
    throw 1;
}

$ g++ -shared -fPIC lib.cc -o liblib.so 
$ g++ main.cc -L. -llib
$ LD_LIBRARY_PATH=. ./a.out

I'm not able to check if it does on darwin, but this is a simplification of the
problem in PR 82172.

Reply via email to