diff mbox

Add ggc-tests.c

Message ID alpine.LSU.2.20.1606121032240.4959@anthias.pfeifer.com
State New
Headers show

Commit Message

Gerald Pfeifer June 12, 2016, 9:04 a.m. UTC
On Mon, 6 Jun 2016, David Malcolm wrote:
> OK for trunk?

As committed on Friday

  2016-06-10  David Malcolm  <dmalcolm@redhat.com>

        * Makefile.in (OBJS): Add ggc-tests.o.
        (GTFILES): Add ggc-tests.c.
        * ggc-tests.c: New file.
        * selftest-run-tests.c (selftest::run_tests): Call
        selftest::ggc_tests_c_tests.
        * selftest.h (selftest::ggc_tests_c_tests): New prototype.

this breaks bootstrap on FreeBSD as follows:

   /scratch/tmp/gerald/OBJ-0610-2205/./gcc/xgcc -B/scratch/tmp/gerald/OBJ-0610-2205
   /./gcc/ -xc -S -c /dev/null -fself-test 
   .../gcc-HEAD/gcc/ggc-tests.c:193: FAIL: ASSERT_FALSE 
   (need_finalization_p <test_struct> ())
   cc1: internal compiler error: in fail, at selftest.c:44

If I disable one particular ASSERT (the first line of the function
below), the bootstrap succeeds:

   test_finalization ()
   {
-->  ASSERT_FALSE (need_finalization_p <test_struct> ());
     ASSERT_TRUE (need_finalization_p <test_struct_with_dtor> ());
   :
   }

And testresults look normal:

   https://gcc.gnu.org/ml/gcc-testresults/2016-06/msg01232.html


At first I thought this might be related to clang being the system
compiler on FreeBSD 10, but it also fails on FreeBSD 9 with GCC 4.2.


The source code of need_finalization_p in ggc.h reads

   template<typename T>
   static inline bool
   need_finalization_p ()
   {
   #if GCC_VERSION >= 4003
     return !__has_trivial_destructor (T);
   #else
     return true;
   #endif
   }

which means your self test is broken by design for any compiler
that is not GCC in at least version 4.3, isn't it?

Okay to commit the straightforward fix for now?

Gerald


2016-06-12  Gerald Pfeifer  <gerald@pfeifer.com>

	* ggc-tests.c (test_finalization): Remove non-portable assertion.
diff mbox

Patch

Index: ggc-tests.c
===================================================================
--- ggc-tests.c	(revision 237336)
+++ ggc-tests.c	(working copy)
@@ -190,7 +190,6 @@ 
 static void
 test_finalization ()
 {
-  ASSERT_FALSE (need_finalization_p <test_struct> ());
   ASSERT_TRUE (need_finalization_p <test_struct_with_dtor> ());
 
   /* Create some garbage.  */