diff options
author | Patrick Palka <ppalka@redhat.com> | 2025-01-16 18:28:17 -0500 |
---|---|---|
committer | Patrick Palka <ppalka@redhat.com> | 2025-01-16 18:28:17 -0500 |
commit | 15a7544e09d81fd35edcc32adc08e494e4debcc2 (patch) | |
tree | 357ab59e896b24a234cde2f39fc3bb69212f28a0 /gcc/config.gcc | |
parent | fed57c8ec95ce3d86e74c5afb73a3a4a499d4ec4 (diff) | |
download | gcc-15a7544e09d81fd35edcc32adc08e494e4debcc2.zip gcc-15a7544e09d81fd35edcc32adc08e494e4debcc2.tar.gz gcc-15a7544e09d81fd35edcc32adc08e494e4debcc2.tar.bz2 |
c++: RESULT_DECL replacement w/ non-reduced ctx->object [PR105440]
After surgically replacing RESULT_DECL within a constexpr call result
(for sake of RVO), we can in some cases simplify the call result
further.
In the below testcase the result of get() during evaluation of a's
initializer is the self-referential CONSTRUCTOR:
{._M_p=(char *) &<retval>._M_local_buf}
which after replacing RESULT_DECL with ctx->object (aka *D.2603, where
the D.2603 temporary points to the current element of _M_elems under
construction) becomes:
{._M_p=(char *) &D.2603->_M_local_buf}
but what we really want is:
{._M_p=(char *) &a._M_elems[0]._M_local_buf}.
so that the value of _M_p is independent of the value of the mutable
D.2603 temporary.
So to that end, it seems we should constexpr evaluate the result again
after RESULT_DECL replacement, which is what this patch implements.
PR c++/105440
gcc/cp/ChangeLog:
* constexpr.cc (cxx_eval_call_expression): If any RESULT_DECLs get
replaced in the call result, try further evaluating the result.
gcc/testsuite/ChangeLog:
* g++.dg/cpp2a/constexpr-dtor17.C: New test.
Reviewed-by: Jason Merrill <jason@redhat.com>
Diffstat (limited to 'gcc/config.gcc')
0 files changed, 0 insertions, 0 deletions