https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127386
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Attachment #65938|0 |1
is obsolete| |
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 65990
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=65990&action=edit
gcc17-pr127386-wip.patch
Updated patch. This one fixes pr94066-2.C and constexpr-init18.C which
regressed with the earlier patch, but regresses constexpr-union12.C.
I think the
11992 /* After verify_constant because reduced_constant_expression_p can unset
11993 CONSTRUCTOR_NO_CLEARING. */
11994 if (TREE_CODE (r) == CONSTRUCTOR && CONSTRUCTOR_NO_CLEARING (r))
11995 {
11996 if (!allow_non_constant)
11997 error ("%qE is not a constant expression because it refers to "
11998 "an incompletely initialized variable", t);
11999 TREE_CONSTANT (r) = false;
12000 non_constant_p = true;
12001 }
code in cxx_eval_outermost_constant_expr is broken in multiple ways. On one
side, no CONSTRUCTOR_NO_CLEARING doesn't mean it isn't embedded somewhere
deeper in the CONSTRUCTOR elts, on the other side at least with this patch
CONSTRUCTOR_NO_CLEARING is set on C++20 union without active members (or set on
e.g. array union elemental subobjects if they have any inactive elements).
So, maybe for now I could just allow the C++ >= 20 unions without elts here,
but perhaps later on we should instead call check_uninit_subobjects from
PR127235
perhaps with some new bool argument to slightly adjust the diagnostics.
That would have also the advantage that users would be diagnosed what actually
is not initialized, rather than the vague diagnostics that not everything is.