https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88572
--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Changing it to a warning, like so:
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -6054,15 +6054,19 @@ reshape_init_r (tree type, reshape_iter *d, bool
first_initializer_p,
{
if (SCALAR_TYPE_P (type))
{
- if (cxx_dialect < cxx11
- /* Isn't value-initialization. */
- || CONSTRUCTOR_NELTS (stripped_init) > 0)
+ if (cxx_dialect < cxx11)
{
if (complain & tf_error)
error ("braces around scalar initializer for type %qT",
type);
init = error_mark_node;
}
+ /* No warning for value-initialization. */
+ else if (CONSTRUCTOR_NELTS (stripped_init) > 0)
+ {
+ warning (0, "braces around scalar initializer for type %qT",
+ type);
+ }
}
else
maybe_warn_cpp0x (CPP0X_INITIALIZER_LISTS);
Causes the test code in comment 0 to issue lots of warnings (as expected) but
also a new error:
88572.cc:14:40: error: cannot bind non-const lvalue reference of type 'invalid'
{aka 'float&'} to an rvalue of type 'float'
14 | invalid scalar_2_brace = braces2<int>(0);
| ~~~~~~~~~~~~^~~
Which means that int{{0}} is now accepted, so my patch isn't right.