https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124012
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Marek Polacek from comment #1)
> (gdb) up
> #1 0x0000000000e0fcd3 in gimplify_var_or_parm_decl (expr_p=0x7fffe982b288)
> at /home/mpolacek/src/gcc/gcc/gimplify.cc:3426
> 3426 gcc_assert (seen_error ());
> (gdb) p *expr_p
> $1 = <var_decl 0x7fffe99c11c8>
> (gdb) pge
> D.2672
> (gdb) trt
> $3 = <record_type 0x7fffe99a99d8 extra_attributes>
> (gdb) pge
> const struct extra_attributes
> (gdb) p consteval_only_p($3)
> $4 = true
>
> so we forgot to wipe a consteval-only var. Mine I guess.
It is more complicated than that.
The underlying var of the structured binding is consteval-only and other
structured binding is also consteval-only, but rvp structured binding is not,
it has
char type. But its DECL_VALUE_EXPR is underlying_var.rvp where underlying_var
is consteval-only, so we need to walk the DECL_VALUE_EXPRs somewhere and if
they aren't on consteval-only type and are actually used somewhere in the code,
we should treat those
the same as if underlying_var.rvp appeared there instead.
Guess such DECL_VALUE_EXPR handling shouldn't be limited to structured
bindings, bet we can have various other reasons why DECL_VALUE_EXPR of a
non-consteval-only variable refers to consteval-only vars (OpenMP privatized
members, etc.).
Given that the structured binding here is constexpr, guess if it was used in
manifestly constant evaluated expression we'd already properly fold it to 0.