[Bug c++/88572] error: braces around scalar initializer - should be a warning

wjwray at gmail dot com gcc-bugzilla@gcc.gnu.org
Wed Jan 9 16:08:00 GMT 2019


--- Comment #13 from Will Wray <wjwray at gmail dot com> ---
Re-reviewing, I notice that the patch I posted in comment #9
now rejects nested empty-brace scalar init:

  int i{{}};

which was previously accepted. So we'll need a decision on this too.

Clang rejects with -pedantic-errors or warns otherwise:
   pedantic error / warning: too many braces around scalar initializer

MSVC rejects:
   error: 'initializing': cannot convert from 'initializer list' to 'int'
   note: Too many braces around initializer for 'int'

I reckon that Clang is right to reject under -pedantic, else accept and warn

This Quora post comes to a similar conclusion:


>accepting {{}} for int seems like a harmless language extension.

More information about the Gcc-bugs mailing list