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

--- Comment #16 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jason Merrill <ja...@gcc.gnu.org>:

https://gcc.gnu.org/g:2da90ad39bf8fa9ee287e040d1f4411cb7a2e7ed

commit r12-6825-g2da90ad39bf8fa9ee287e040d1f4411cb7a2e7ed
Author: Will Wray <wjw...@gmail.com>
Date:   Fri Jan 14 19:28:53 2022 -0500

    c++: designated init of char array by string constant [PR55227]

    There are two underlying bugs in the designated initialization of char
array
    fields by string literals that cause:

    (1) Rejection of valid cases with:
      (a) brace-enclosed string literal initializer (of any valid size), or
      (b) unbraced string literal shorter than the target char array field.

    (2) Acceptance of invalid cases with designators appearing within the
braces
        of a braced string literal, in which case the bogus 'designator' was
        being entirely ignored and the string literal treated as a positional
        initializer.

    The fixes above allow to address a FIXME in cp_complete_array_type:

      /* FIXME: this code is duplicated from reshape_init.
         Probably we should just call reshape_init here?  */

    I believe that this was obstructed by the designator bugs (see comment here
    https://patchwork.ozlabs.org/project/gcc/list/?series=199783)

            PR c++/55227

    gcc/cp/ChangeLog:

            * decl.cc (reshape_init_r): Only call has_designator_check when
            first_initializer_p or for the inner constructor element.
            (cp_complete_array_type): Call reshape_init on braced-init-list.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp2a/desig21.C: New test.

Reply via email to