[C++, tree-ssa] PATCH to preevaluate new-initializer args

Jason Merrill jason@redhat.com
Tue Nov 18 06:41:00 GMT 2003


This patch implements the FIXME in build_new_1: we now preevaluate all of
the arguments to the constructor for a new'd object, so that we can
do the actual memory allocation last and thereby minimize the extent of the
EH region for freeing the memory if the constructor throws an exception.
Previously the region covered the whole statement and we needed to control
whether or not we actually run the cleanup using a boolean temporary
variable; this is much simpler and should be easier for the optimizers to
deal with.

This patch changes the observable behavior on
g++.old-deja/g++.martin/new1.C; we used to allocate the memory before
evaluating any of the constructor args, now we do the opposite.  This order
is unspecified in the standard, so both are conformant.

While I was there, I removed the 'pedantic' check for the pedwarn about
specifying an initializer in array new.  This might be worth applying to
the trunk as well.  The whole patch would be suitable for the trunk, except
that we're now in stage 3.

Tested athlon-pc-linux-gnu, applied to tree-ssa branch.

2003-11-17  Jason Merrill  <jason@redhat.com>

	* init.c (build_new_1): Preevaluate initializer.  Simplify EH code.
	(build_init): Call a constructor rather than call build_aggr_init
	for classes.
	* except.c (stabilize_throw_expr): Remove.
	(build_throw): Use stabilize_init instead of stabilize_throw_expr.
	* tree.c (stabilize_call, stabilize_init): New fns.
	* call.c (build_over_call): A constructor no longer returns the
	address of the object.

	* init.c (build_new_1): Preevaluate placement args.
	* call.c (build_op_delete_call): Don't expose placement args to
	overload resolution.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: text/x-patch
Size: 26190 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20031118/50bd9a82/attachment.bin>


More information about the Gcc-patches mailing list