[Bug c++/95369] braced-init-list with designated initializers as template-argument rejected

cvs-commit at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Jun 16 17:21:36 GMT 2020


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

--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Marek Polacek <mpolacek@gcc.gnu.org>:

https://gcc.gnu.org/g:04afaf4575ff239279cfa34aff17101345451965

commit r11-1392-g04afaf4575ff239279cfa34aff17101345451965
Author: Marek Polacek <polacek@redhat.com>
Date:   Mon Jun 15 15:31:32 2020 -0400

    c++: Don't allow designated initializers with non-aggregates [PR95369]

    Another part of 95369 is that we accept designated initializers with
    non-aggregate types.  That seems to be wrong since they're part of
    aggregate initialization.  clang/icc also reject it.

    There are multiple contexts where we can use designated initializers:
    function-like casts, member list initializers, NTTP, etc.  I've adjusted
    add_list_candidates and implicit_conversion_error in order to to detect
    this case.

    gcc/cp/ChangeLog:

            PR c++/95369
            * call.c (add_list_candidates): Return if a designated initializer
            is used with a non-aggregate.
            (implicit_conversion_error): Give an error for the case above.

    gcc/testsuite/ChangeLog:

            PR c++/95369
            * g++.dg/cpp2a/desig11.C: Adjust dg-error.
            * g++.dg/cpp2a/desig16.C: New test.


More information about the Gcc-bugs mailing list