Hi, The below patch skips gcc.dg/addr_equal-1.c if the target keeps null pointer checks.
The test fails for such targets (avr, in my case) because the address comparison in the below code does not resolve to a constant, causing builtin_constant_p to return false and fail the test. /* Variables and functions do not share same memory locations otherwise. */ if (!__builtin_constant_p ((void *)undef_fn0 == (void *)&undef_var0)) abort (); For targets that delete null pointer checks, the equality comparison expression is optimized away to 0, as the code in match.pd knows they can only be equal if they are both NULL, which cannot be true since flag-delete-null-pointer-checks is on. For targets that keep null pointer checks, 0 is a valid address and the comparison expression is left as is, and that causes a later pass to fold the builtin_constant_p to a false value, resulting in the test failure. If this is ok, could someone commit please? I don't have commit access. Regards Senthil gcc/testsuite/ChangeLog 2015-09-28 Senthil Kumar Selvaraj <senthil_kumar.selva...@atmel.com> * gcc.dg/addr_equal-1.c: Skip test if target keeps null pointer checks. diff --git gcc/testsuite/gcc.dg/addr_equal-1.c gcc/testsuite/gcc.dg/addr_equal-1.c index 94499f0..957b03a 100644 --- gcc/testsuite/gcc.dg/addr_equal-1.c +++ gcc/testsuite/gcc.dg/addr_equal-1.c @@ -3,6 +3,7 @@ /* { dg-require-weak "" } */ /* { dg-require-alias "" } */ /* { dg-options "-O2" } */ +/* { dg-skip-if "" keeps_null_pointer_checks } */ void abort (void); extern int undef_var0, undef_var1; extern __attribute__ ((weak)) int weak_undef_var0;