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:
parent
72bd94e141
commit
0e8a1f1e08
3 changed files with 9 additions and 7 deletions
|
|
@ -16,9 +16,7 @@ main (int, char**)
|
||||||
{
|
{
|
||||||
cout << "\n.gulp.\n";
|
cout << "\n.gulp.\n";
|
||||||
|
|
||||||
Factory fab1;
|
Subject& ref1 = fab();
|
||||||
Subject& ref1 = fab1();
|
|
||||||
|
|
||||||
Subject& sub2 = test::fabricate();
|
Subject& sub2 = test::fabricate();
|
||||||
|
|
||||||
cout << "sub1="<< &ref1 << " sub2="<< &sub2 <<"\n";
|
cout << "sub1="<< &ref1 << " sub2="<< &sub2 <<"\n";
|
||||||
|
|
|
||||||
|
|
@ -20,15 +20,16 @@ namespace test {
|
||||||
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
// Holder<Subject> fab2;
|
lib::singleton::UseSubclass<Subject> typeID;
|
||||||
Factory fab2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Factory fab(typeID);
|
||||||
|
|
||||||
|
|
||||||
Subject&
|
Subject&
|
||||||
fabricate()
|
fabricate()
|
||||||
{
|
{
|
||||||
return fab2();
|
return fab();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,10 @@ namespace test {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef lib::Singleton<Subject> Factory;
|
typedef lib::SingletonSub<Subject> Factory;
|
||||||
|
|
||||||
|
extern Factory fab;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Subject& fabricate();
|
Subject& fabricate();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue