https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92812
--- Comment #9 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Marek Polacek <mpola...@gcc.gnu.org>: https://gcc.gnu.org/g:2ec803e768a820c9208fea2e8b144ee359379139 commit r11-2681-g2ec803e768a820c9208fea2e8b144ee359379139 Author: Marek Polacek <pola...@redhat.com> Date: Fri Jul 10 17:39:54 2020 -0400 c++: Fixing the wording of () aggregate-init [PR92812] P1975R0 tweaks the static_cast wording: it says that "An expression e can be explicitly converted to a type T if [...] T is an aggregate type having a first element x and there is an implicit conversion sequence from e to the type of x." This already works for classes, e.g.: struct Aggr { int x; int y; }; Aggr a = static_cast<Aggr>(1); for which we create TARGET_EXPR <D.2111, {.x=1}>. The proposal also mentions "If T is ``array of unknown bound of U'', this direct-initialization defines the type of the expression as U[1]" which suggest that this should work for arrays (they're aggregates too, after all): int (&&r)[3] = static_cast<int[3]>(42); int (&&r2)[1] = static_cast<int[]>(42); So I handled that specifically in build_static_cast_1: wrap the expression in { } and initialize from that. For the 'r' case above this creates TARGET_EXPR <D.2083, {42}>. There are multiple things in play, as usual, so the tests test brace elision, narrowing, explicit constructors, and lifetime extension too. I think it's in line with what we discussed on the core reflector. gcc/cp/ChangeLog: PR c++/92812 * typeck.c (build_static_cast_1): Implement P1975R0 by allowing static_cast to aggregate type. gcc/testsuite/ChangeLog: PR c++/92812 * g++.dg/cpp2a/paren-init27.C: New test. * g++.dg/cpp2a/paren-init28.C: New test. * g++.dg/cpp2a/paren-init29.C: New test. * g++.dg/cpp2a/paren-init30.C: New test. * g++.dg/cpp2a/paren-init31.C: New test. * g++.dg/cpp2a/paren-init32.C: New test.