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
This commit is contained in:
Fischlurch 2013-09-30 02:09:31 +02:00
parent 72bd94e141
commit 0e8a1f1e08
3 changed files with 9 additions and 7 deletions

View file

@ -16,9 +16,7 @@ main (int, char**)
{
cout << "\n.gulp.\n";
Factory fab1;
Subject& ref1 = fab1();
Subject& ref1 = fab();
Subject& sub2 = test::fabricate();
cout << "sub1="<< &ref1 << " sub2="<< &sub2 <<"\n";

View file

@ -20,15 +20,16 @@ namespace test {
namespace {
// Holder<Subject> fab2;
Factory fab2;
lib::singleton::UseSubclass<Subject> typeID;
}
Factory fab(typeID);
Subject&
fabricate()
{
return fab2();
return fab();
}

View file

@ -34,7 +34,10 @@ namespace test {
};
typedef lib::Singleton<Subject> Factory;
typedef lib::SingletonSub<Subject> Factory;
extern Factory fab;
Subject& fabricate();