throwing from (singleton) constructor gives segmentation fault
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
gcc-defaults (Ubuntu) |
Confirmed
|
Undecided
|
Unassigned |
Bug Description
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_
}
};
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_
what(): throw
Aborted (core dumped)
ProblemType: Bug
DistroRelease: Ubuntu 12.04
Package: g++ 4:4.6.3-1ubuntu5
ProcVersionSign
Uname: Linux 3.2.0-27-
NonfreeKernelMo
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)
Changed in gcc-defaults (Ubuntu): | |
status: | New → Confirmed |
summary: |
- throwing from (singleton) constructor gives segmentation fault + gcc doesn't isssue a strict aliasing warning on a code that seems to + break it |
summary: |
- gcc doesn't isssue a strict aliasing warning on a code that seems to - break it + throwing from (singleton) constructor gives segmentation fault |