This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [C++ PATCH] PR c++/35878


Hi!

On Tue, Mar 21, 2017 at 03:21:11AM +0200, Ville Voutilainen wrote:

Formatting etc. nits:

> 2017-03-21  Ville Voutilainen  <ville.voutilainen@gmail.com>
> 
>     gcc/
> 
>     PR c++/35878

This should go into gcc/cp/ ChangeLog

>     * cp/init.c (std_placement_new_fn_p): New.

without cp/ here.

>     (build_new_1): Call it.

> +/* 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)

> @@ -3171,7 +3186,8 @@ build_new_1 (vec<tree, va_gc> **placement, tree type, tree nelts,
>       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);
> +  check_new = flag_check_new
> +    || (nothrow && !std_placement_new_fn_p (alloc_fn));

This should be either:
  check_new
    = flag_check_new || (nothrow && !std_placement_new_fn_p (alloc_fn));
or
  check_new = (flag_check_new
	       || (nothrow && !std_placement_new_fn_p (alloc_fn)));
i.e. || should not be when on next line at different column than
flag_check_new (and the ()s to make emacs happy).

> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/init/pr35878_1.C
> @@ -0,0 +1,21 @@
> +// { 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.

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]