diff options
author | robertl <robertl@138bc75d-0d04-0410-961f-82ee72b054a4> | 1998-07-10 21:45:18 +0000 |
---|---|---|
committer | robertl <robertl@138bc75d-0d04-0410-961f-82ee72b054a4> | 1998-07-10 21:45:18 +0000 |
commit | 4b015ce1adde16bc67d4d1bc37a3c0c623527b2d (patch) | |
tree | 364ffb118769386354eaab4fc9e4d4e2dc920c7c /gcc/testsuite | |
parent | 144e7e1a4b523d2d88b071b4d0ea09ffa8a27fde (diff) | |
download | gcc-4b015ce1adde16bc67d4d1bc37a3c0c623527b2d.tar.gz |
* g++.other/singleton.C: Return error value instead of taking
SIGSEGV.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@21054 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite')
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.old-deja/g++.other/singleton.C | 24 |
2 files changed, 18 insertions, 11 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9fe92bd055f..d48ad946a9e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +Fri Jul 10 23:43:33 1998 Martin von Loewis <martin@mira.isdn.cs.tu-berlin.de> + + * g++.other/singleton.C: Return error value instead of taking + SIGSEGV. + Fri Jul 10 10:02:03 1998 Klaus-Georg Adams <Klaus-Georg.Adams@chemie.uni-karlsruhe.de> * g++.other/singleton.C: New test. Warning is under dispute. diff --git a/gcc/testsuite/g++.old-deja/g++.other/singleton.C b/gcc/testsuite/g++.old-deja/g++.other/singleton.C index 32722c31373..fda64fb9a46 100644 --- a/gcc/testsuite/g++.old-deja/g++.other/singleton.C +++ b/gcc/testsuite/g++.old-deja/g++.other/singleton.C @@ -1,10 +1,12 @@ +// execution test - re-initialization of statics XFAIL *-*-* // This tests two things: -// 1. there is an annoying warning. singleton.C:27: warning: `class -// singleton' only defines private constructors and has no friends egcs -// fails to see that there is a public static accessor function. +// 1. there is an annoying warning. +// singleton.C:26: warning: `class singleton' only defines private constructors +and has no friends +// egcs fails to see that there is a public static accessor function. // 2. the program crashes, because apparently the static variable s in // singleton::instance() is considered constructed although the ctor -// exited via an exception. +// exited via an exception. (crash changed to non-zero return here) class singleton { public: @@ -12,19 +14,18 @@ public: static singleton s; return s; } - ~singleton() { delete sigsegv; } - int crash() { return *sigsegv; } + int check() {return initialized;} private: - singleton() : sigsegv(0) { + singleton() : initialized(1) { if ( counter++ == 0 ) throw "just for the heck of it"; - sigsegv = new int(0); + initialized = 2; } singleton( const singleton& rhs ); void operator=( const singleton& rhs ); - int* sigsegv; + int initialized; static int counter; -}; +}; // gets bogus error - class is not useless XFAIL *-*-* int singleton::counter; @@ -32,7 +33,8 @@ int main() { while (1) { try { - return singleton::instance().crash(); + return singleton::instance().ok()-2; } catch (...) { } } } + |