https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107926
Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED Assignee|unassigned at gcc dot gnu.org |pinskia at gcc dot gnu.org --- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> --- This patch I am testing which should fix the issue: diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc index e06f052eb46..0fc382cc5eb 100644 --- a/gcc/c/c-typeck.cc +++ b/gcc/c/c-typeck.cc @@ -10623,17 +10623,22 @@ process_init_element (location_t loc, struct c_expr value, bool implicit, /* Handle superfluous braces around string cst as in char x[] = {"foo"}; */ - if (string_flag - && constructor_type + if (constructor_type && !was_designated && TREE_CODE (constructor_type) == ARRAY_TYPE && INTEGRAL_TYPE_P (TREE_TYPE (constructor_type)) && integer_zerop (constructor_unfilled_index)) { if (constructor_stack->replacement_value.value) - error_init (loc, "excess elements in %<char%> array initializer"); - constructor_stack->replacement_value = value; - return; + { + error_init (loc, "excess elements in %<char%> array initializer"); + return; + } + else if (string_flag) + { + constructor_stack->replacement_value = value; + return; + } } if (constructor_stack->replacement_value.value != NULL_TREE)