[3.4 patch]: Fix PR c++/21583 badalloc1.C testcase
Kaveh R. Ghazi
ghazi@caipclassic.rutgers.edu
Tue Feb 21 03:09:00 GMT 2006
This patch addresses c++/21583 as noted in the PR by backporting the
updates to the badalloc1.C testcase from the 4.0 branch.
Note there are some more updates on mainline/4.1 to this testcase,
e.g. PR 19888, but that is a separate issue tracked in a separate PR.
And I don't have the platform(s) in question on which to test these
further updates.
Tested via 3.4 "make check" on sparc-sun-solaris2.10, the testcase now
passes.
Okay for 3.4?
Thanks,
--Kaveh
2006-02-20 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
PR c++/21583
Backport:
2004-11-30 Loren James Rittle <ljrittle@acm.org>
* g++.old-deja/g++.eh/badalloc1.C (arena_size): Bump up to 262144
to support new requirements on FreeBSD 5.
2004-11-26 Mark Mitchell <mark@codesourcery.com>
* g++.old-deja/g++.eh/badalloc1.C: Robustify.
diff -rup orig/egcc-3.4-SVN20060219/gcc/testsuite/g++.old-deja/g++.eh/badalloc1.C egcc-3.4-SVN20060219/gcc/testsuite/g++.old-deja/g++.eh/badalloc1.C
--- orig/egcc-3.4-SVN20060219/gcc/testsuite/g++.old-deja/g++.eh/badalloc1.C 2006-01-23 00:06:15.000000000 -0500
+++ egcc-3.4-SVN20060219/gcc/testsuite/g++.old-deja/g++.eh/badalloc1.C 2006-02-20 20:52:30.864092621 -0500
@@ -14,11 +14,10 @@ extern "C" void *memcpy(void *, const vo
#ifdef STACK_SIZE
const int arena_size = 256;
#else
-#ifdef __FreeBSD__
-// FreeBSD with threads requires even more space at initialization time.
-#include "bits/c++config.h"
-#include "bits/gthr.h"
-const int arena_size = 131072;
+#if defined(__FreeBSD__) || defined(__sun__)
+// FreeBSD with threads and Solaris with threads require even more
+// space at initialization time. FreeBSD 5 now requires over 131072 bytes.
+const int arena_size = 262144;
#else
const int arena_size = 32768;
#endif
@@ -105,16 +104,15 @@ void fn_catchthrow() throw(int)
int main()
{
-#ifdef __FreeBSD__
-// FreeBSD with threads fails the test unless each thread primes itself.
- if (__gthread_active_p())
- {
- try{fn_throw();}
- catch(int a){}
- }
-// This was added to test with well-known idiom to detect regressions here
-// rather than always failing with -pthread.
-#endif
+ /* On some systems (including FreeBSD and Solaris 2.10),
+ __cxa_get_globals will try to call "malloc" when threads are in
+ use. Therefore, we throw one exception up front so that
+ __cxa_get_globals is all set up. Ideally, this would not be
+ necessary, but it is a well-known idiom, and using this technique
+ means that we can still validate the fact that exceptions can be
+ thrown when malloc fails. */
+ try{fn_throw();}
+ catch(int a){}
fail = 1;
More information about the Gcc-patches
mailing list