diff --git a/research/clang-static-init-1.cpp b/research/clang-static-init-1.cpp index 020f469b3..6c473de41 100644 --- a/research/clang-static-init-1.cpp +++ b/research/clang-static-init-1.cpp @@ -2,16 +2,26 @@ #include "clang-static-init.hpp" +test::Subject& +localFunction() +{ + return test::fab.get(); +} + int main (int, char**) { - cout << "\nStart Testcase: invoking two instances of the configurable singleton factory...\n"; + cout << "\nStart Testcase: invoking two instances of the configurable singleton factory...\n\n"; test::Subject& ref1 = test::fab.get(); - test::Subject& sub2 = test::fabricate(); + test::Subject& sub2 = test::fabricate(); ///NOTE: invoking get() from within another compilation unit reveales the problem + test::Subject& sub3 = localFunction(); - cout << "sub1="<< &ref1 << " sub2="<< &sub2 <<"\n"; + cout << "sub1=" << &ref1 + << "\nsub2="<< &sub2 + << "\nsub3="<< &sub3 + << "\n"; return 0; diff --git a/research/clang-static-init.hpp b/research/clang-static-init.hpp index 6597e8b05..272e76d08 100644 --- a/research/clang-static-init.hpp +++ b/research/clang-static-init.hpp @@ -22,7 +22,7 @@ namespace test { { if (!instance) { - cout << "Singleton Factory: invoke Fabrication ---> instance="<<&instance<<"...\n"; + cout << "Singleton Factory: invoke Fabrication ---> address of static instance variable: "<<&instance<<"...\n"; instance = Fac::create(); }