lumiera_/research/clang-static-init-2.cpp
Ichthyostega 0e8a1f1e08 bughunt: use a single SingletonSub instance in two compilation units --> HIT
basically this reproduces the problem in a simplified setup.
Especially note that we're going through a single instance of the factory,
yet still this single instance 'sees' two different locations of the
class static variable
2013-10-06 23:17:18 +02:00

36 lines
416 B
C++

#include "clang-static-init.hpp"
#include <iostream>
using std::cout;
using std::endl;
namespace test {
int Subject::cnt = 0;
Subject::Subject()
{
++cnt;
std::cout << "Subject("<<cnt<<")\n";
}
namespace {
lib::singleton::UseSubclass<Subject> typeID;
}
Factory fab(typeID);
Subject&
fabricate()
{
return fab();
}
} // namespace test