Skip to content
Snippets Groups Projects
Commit c7ac1de5 authored by Jason Merrill's avatar Jason Merrill
Browse files

c++: only cache constexpr calls that are constant exprs

In reviewing Nathaniel's patch for PR70331, it occurred to me that instead
of looking for various specific problematic things in the result of a
constexpr call to decide whether to cache it, we should use
reduced_constant_expression_p.

The change to that function is to avoid crashing on uninitialized objects of
non-class type.

In a trial version of this patch I checked to see what cases this stopped
caching; most were instances of partially-initialized return values, which
seem fine to not cache.  Some were returning pointers to expiring local
variables, which we definitely want not to cache.  And one was bit-cast3.C,
which will be handled in a follow-up patch.

gcc/cp/ChangeLog:

	* constexpr.cc (cxx_eval_call_expression): Only cache
	reduced_constant_expression_p results.
	(reduced_constant_expression_p): Handle CONSTRUCTOR of scalar type.
	(cxx_eval_constant_expression): Fold vectors here.
	(cxx_eval_bare_aggregate): Not here.
parent c5e9927b
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment