On Tue, Mar 21, 2017 at 09:03:54AM +0200, Ville Voutilainen wrote: > On 21 March 2017 at 08:55, Ville Voutilainen > <ville.voutilai...@gmail.com> wrote: > >>> +// { dg-options "-O2 --std=gnu++11" } > >> > >> -O2 -std=gnu++11 is enough, no need for double dash --std=gnu++11. > >> > >>> +// { dg-do compile } > >>> +// { dg-final { scan-assembler "test.*%rdi, %rdi" { target i?86-*-* > >>> x86_64-*-* } } } > >> > >> This will surely fail on 32-bit or with -mx32. So either you need to use > >> it > >> on { target { { i?86-*-* x86_64-*-* } && lp64 } } only, or perhaps instead > >> of scanning assembler add -fdump-tree-optimized to dg-options and > >> scan-tree-dump for the NULL? pointer comparison there. > > > > I weakly vote for the former, since that's less intrusive. I managed > > to commit the patch before > > I saw these remarks, so we need to patch that fix in as a separate tweak. > > So, shall I just push in the attached?
I've tested in the mean time the following patch with both gcc from yesterday where pr35878_3.C fails as expected, and with the latest cc1plus where it succeeds both with -m32 and -m64. Scanning the tree dump has the advantage that you test it everywhere, it works even with -masm=intel etc. --- gcc/cp/ChangeLog.jj 2017-03-21 07:57:00.000000000 +0100 +++ gcc/cp/ChangeLog 2017-03-21 08:03:41.427958947 +0100 @@ -1,7 +1,7 @@ 2017-03-21 Ville Voutilainen <ville.voutilai...@gmail.com> PR c++/35878 - * cp/init.c (std_placement_new_fn_p): New. + * init.c (std_placement_new_fn_p): New. (build_new_1): Call it. 2017-03-20 Jason Merrill <ja...@redhat.com> --- gcc/cp/init.c.jj 2017-03-21 07:57:00.000000000 +0100 +++ gcc/cp/init.c 2017-03-21 08:04:13.226549930 +0100 @@ -2710,7 +2710,8 @@ malloc_alignment () /* Determine whether an allocation function is a namespace-scope non-replaceable placement new function. See DR 1748. TODO: Enable in all standard modes. */ -static bool std_placement_new_fn_p (tree alloc_fn) +static bool +std_placement_new_fn_p (tree alloc_fn) { if ((cxx_dialect > cxx14) && DECL_NAMESPACE_SCOPE_P (alloc_fn)) { @@ -3200,8 +3201,8 @@ build_new_1 (vec<tree, va_gc> **placemen So check for a null exception spec on the op new we just called. */ nothrow = TYPE_NOTHROW_P (TREE_TYPE (alloc_fn)); - check_new = flag_check_new - || (nothrow && !std_placement_new_fn_p (alloc_fn)); + check_new + = flag_check_new || (nothrow && !std_placement_new_fn_p (alloc_fn)); if (cookie_size) { --- gcc/testsuite/g++.dg/init/pr35878_1.C.jj 2017-03-21 07:56:59.000000000 +0100 +++ gcc/testsuite/g++.dg/init/pr35878_1.C 2017-03-21 08:10:07.020008447 +0100 @@ -1,6 +1,8 @@ -// { dg-options "-O2 --std=gnu++11" } +// PR c++/35878 // { dg-do compile } -// { dg-final { scan-assembler "test.*%rdi, %rdi" { target i?86-*-* x86_64-*-* } } } +// { dg-options "-O2 -std=gnu++11 -fdump-tree-optimized" } +// { dg-final { scan-tree-dump-times "v_\[0-9]+\\(D\\) \[=!]= 0" 1 "optimized" } } + #include <new> #include <utility> --- gcc/testsuite/g++.dg/init/pr35878_2.C.jj 2017-03-21 07:56:59.000000000 +0100 +++ gcc/testsuite/g++.dg/init/pr35878_2.C 2017-03-21 08:10:35.021649003 +0100 @@ -1,6 +1,8 @@ -// { dg-options "-O2 --std=gnu++17 -fcheck-new" } +// PR c++/35878 // { dg-do compile } -// { dg-final { scan-assembler "test.*%rdi, %rdi" { target i?86-*-* x86_64-*-* } } } +// { dg-options "-O2 -std=gnu++17 -fcheck-new -fdump-tree-optimized" } +// { dg-final { scan-tree-dump-times "v_\[0-9]+\\(D\\) \[=!]= 0" 1 "optimized" } } + #include <new> #include <utility> --- gcc/testsuite/g++.dg/init/pr35878_3.C.jj 2017-03-21 07:56:59.000000000 +0100 +++ gcc/testsuite/g++.dg/init/pr35878_3.C 2017-03-21 08:11:02.182300354 +0100 @@ -1,6 +1,8 @@ -// { dg-options "-O2 --std=gnu++17" } +// PR c++/35878 // { dg-do compile } -// { dg-final { scan-assembler-not "test.*%rdi, %rdi" { target i?86-*-* x86_64-*-* } } } +// { dg-options "-O2 -std=gnu++17 -fdump-tree-optimized" } +// { dg-final { scan-tree-dump-not "v_\[0-9]+\\(D\\) \[=!]= 0" "optimized" } } + #include <new> #include <utility> Jakub