The warnings for variable pmf are not produced as expected in this test. The test was introduced by a patch for PR44277. FAIL: g++.dg/cpp0x/Wzero-as-null-pointer-constant-1.C (test for warnings, line 66) FAIL: g++.dg/cpp0x/Wzero-as-null-pointer-constant-1.C (test for warnings, line 78) FAIL: g++.dg/cpp0x/Wzero-as-null-pointer-constant-1.C (test for warnings, line 90) FAIL: g++.dg/cpp0x/Wzero-as-null-pointer-constant-1.C (test for warnings, line 102) FAIL: g++.dg/warn/Wzero-as-null-pointer-constant-1.C -std=gnu++98 (test for warnings, line 53) FAIL: g++.dg/warn/Wzero-as-null-pointer-constant-1.C -std=gnu++98 (test for warnings, line 65) FAIL: g++.dg/warn/Wzero-as-null-pointer-constant-1.C -std=gnu++98 (test for warnings, line 77) FAIL: g++.dg/warn/Wzero-as-null-pointer-constant-1.C -std=gnu++98 (test for warnings, line 89) FAIL: g++.dg/warn/Wzero-as-null-pointer-constant-1.C -std=gnu++11 (test for warnings, line 53) FAIL: g++.dg/warn/Wzero-as-null-pointer-constant-1.C -std=gnu++11 (test for warnings, line 65) FAIL: g++.dg/warn/Wzero-as-null-pointer-constant-1.C -std=gnu++11 (test for warnings, line 77) FAIL: g++.dg/warn/Wzero-as-null-pointer-constant-1.C -std=gnu++11 (test for warnings, line 89) Target: arm-none-eabi Configured with: --with-cpu=cortex-a9 --with-float=softfp --with-fpu=neon --enable-checking=release --disable-gdbtk --disable-werror --disable-tui --disable-rda --disable-sid --disable-utils --disable-lto --disable-lto --disable-werror --disable-shared --disable-nls --disable-threads --disable-tls --enable-checking=yes --enable-languages=c,c++,fortran --with-newlib Thread model: single gcc version 4.7.0 20111107 (experimental) (GCC)
That's a pity, but personally frankly I don't think I will be able to seriously debug for this target in the near future. Or maybe Jason has something to suggest. Otherwise I propose to xfail on arm, for 4.7.
(In reply to comment #1) > I don't think I will be able to seriously > debug for this target in the near future. It's easy to build a cross-compiler for compile-time tests like this. Just .../configure --target arm-none-eabi --enable-languages=c++ && make all-gcc should get as far as building cc1plus, which is all you need to debug most PRs.
I'll see what I can do... At the moment really I have no idea why for this target only we have a different behavior.
Unexpectedly ;) I'm making progress debugging this: what happens is that, for arm, in cp_build_binary_op, case EQ_EXPR (this is for 'if (pmf == 0)') here: if (TARGET_PTRMEMFUNC_VBIT_LOCATION == ptrmemfunc_vbit_in_delta) { tree pfn0 = pfn_from_ptrmemfunc (op0); tree delta0 = delta_from_ptrmemfunc (op0); tree e1 = cp_build_binary_op (location, EQ_EXPR, pfn0, build_zero_cst (TREE_TYPE (pfn0)), complain); tree e2 = cp_build_binary_op (location, BIT_AND_EXPR, delta0, integer_one_node, complain); e2 = cp_build_binary_op (location, EQ_EXPR, e2, integer_zero_node, complain); op0 = cp_build_binary_op (location, TRUTH_ANDIF_EXPR, e1, e2, complain); op1 = cp_convert (TREE_TYPE (op0), integer_one_node); } else { op0 = build_ptrmemfunc_access_expr (op0, pfn_identifier); op1 = cp_convert (TREE_TYPE (op0), op1); } the condition is true, thus we don't call cp_convert with op1, which is integer_zero_node here, instead we pass integer_one_node to cp_convert and the warning down in cp_convert_to_pointer cannot possibly trigger (actually, for arm we don't even reach cp_convert_to_pointer) Thus, an idea for fixing the problem would be just warn right here for arm and similar targets, because here we know that op1 is indeed integer_zero_node (and that TYPE_PTRMEMFUNC_P (type0) is true of course) Jason, can you imagine something neater?
Created attachment 25873 [details] Sanity checked on x86_64-linux and lightly tested arm-none-eabi In practice, this works for me. Maybe Greta can test it more carefully.
Thanks for fixing it, Paolo. Tested as follows. Successful cross-build of the patch version for arm-none-eabi target, configured as before. No regression on qemu for check-g++. The tests for g++.dg/cpp0x/Wzero-as-null-pointer-constant-1.C all pass. Can you see the patch committed to trunk, please? Thank you, Greta
Author: paolo Date: Tue Nov 22 15:04:27 2011 New Revision: 181620 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=181620 Log: 2011-11-22 Paolo Carlini <paolo.carlini@oracle.com> PR c++/51196 * typeck.c (cp_build_binary_op, [case EQ_EXPR]): For targets having TARGET_PTRMEMFUNC_VBIT_LOCATION == ptrmemfunc_vbit_in_delta, do here the -Wzero-as-null-pointer-constant warning for pmf == 0. Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/typeck.c
Thanks a lot Greta for testing, patch applied!