Public bug reported: Hi, the following program gets a segmentation fault. It works OK on another machine (g++ (GCC) 4.1.2 20080704 (Red Hat 4.1.2-52)).
#include <iostream> #include <string> #include <stdexcept> using namespace std; class A { public: // Singleton static A & instance(); private: A() { throw std::runtime_error("throw\n"); } }; A & A::instance() { static A inst; return inst; } int main () { const A & a = A::instance(); return 0; } % g++ -o foo foo.cc % ./foo terminate called after throwing an instance of 'std::runtime_error' what(): throw Aborted (core dumped) ProblemType: Bug DistroRelease: Ubuntu 12.04 Package: g++ 4:4.6.3-1ubuntu5 ProcVersionSignature: Ubuntu 3.2.0-27.43-generic-pae 3.2.21 Uname: Linux 3.2.0-27-generic-pae i686 NonfreeKernelModules: nvidia ApportVersion: 2.0.1-0ubuntu13 Architecture: i386 Date: Mon Sep 17 15:39:58 2012 InstallationMedia: Ubuntu 9.10 "Karmic Koala" - Release i386 (20091028.5) SourcePackage: gcc-defaults UpgradeStatus: Upgraded to precise on 2012-06-06 (103 days ago) ** Affects: gcc-defaults (Ubuntu) Importance: Undecided Status: New ** Tags: apport-bug i386 precise -- You received this bug notification because you are a member of Ubuntu Bugs, which is subscribed to Ubuntu. https://bugs.launchpad.net/bugs/1051972 Title: throwing from (singleton) constructor gives segmentation fault To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/gcc-defaults/+bug/1051972/+subscriptions -- ubuntu-bugs mailing list ubuntu-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs