https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92015

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dmalcolm at gcc dot gnu.org,
                   |                            |jakub at gcc dot gnu.org

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
So, we try to constexpr evaluate
(TARGET_EXPR <D.2344, {.c=VIEW_CONVERT_EXPR<char[6]>("hello")}>).c[0]
which has a location wrapper in.  Normally location wrappers are stripped early
in cxx_eval_constant_expression: STRIP_ANY_LOCATION_WRAPPER (t);
The problem is that when cxx_eval_constant_expression is called on CONSTRUCTOR,
it does:
5233          if (TREE_CONSTANT (t) && reduced_constant_expression_p (t))
5234            {
5235              /* Don't re-process a constant CONSTRUCTOR, but do fold it to
5236                 VECTOR_CST if applicable.  */
5237              verify_constructor_flags (t);
5238              if (TREE_CONSTANT (t))
5239                return fold (t);
5240            }
5241          r = cxx_eval_bare_aggregate (ctx, t, lval,
5242                                       non_constant_p, overflow_p);
While cxx_eval_bare_aggregate strips them away, as it recurses on each element,
if the CONSTRUCTOR is TREE_CONSTANT and reduced constant expression (which is
happy about STRING_CSTs wrapped in VIEW_CONVERT_EXPRs or about INTEGER_CSTs
wrapped in NON_LVALUE_EXPRs, because initializer_constant_valid_p_1 recurses on
both), nothing is changed.
The easiest fix is IMHO when we are picking something out of a CONSTRUCTOR add
the STRIP_ANY_LOCATION_WRAPPER there.

Reply via email to