This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Add ggc-tests.c
- From: Gerald Pfeifer <gerald at pfeifer dot com>
- To: David Malcolm <dmalcolm at redhat dot com>, gcc-patches at gcc dot gnu dot org
- Cc: Jeff Law <law at redhat dot com>
- Date: Sun, 12 Jun 2016 11:04:19 +0200 (CEST)
- Subject: Re: [PATCH] Add ggc-tests.c
- Authentication-results: sourceware.org; auth=none
- References: <1465248701-48608-1-git-send-email-dmalcolm at redhat dot com>
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.
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. */