Testcase: extern long double l; struct S { S(int) {} }; S s[] = { l }; This is supposed to be ill-formed because of narrowing. GCC does not reject the code, nor it warns (as it usually does for narrowing). The relevant rule is in [dcl.init.aggr]: https://eel.is/c++draft/dcl.init.aggr#4.2.sentence-2 > Otherwise, the element is copy-initialized from the corresponding initializer-clause or is initialized with the brace-or-equal-initializer of the corresponding designated-initializer-clause. > If that initializer is of the form assignment-expression or = assignment-expression and a narrowing conversion ([dcl.init.list]) is required to convert the expression, the program is ill-formed. That rule has been changed in C++20 with designated initializers, but the same one was also there for C++17 and before, e.g. https://timsong-cpp.github.io/cppwp/n4659/dcl.init.aggr#3 For comparison, Clang accepts with no warnings, but MSVC warns about narrowing.
Confirmed, this should be a -Wnarrowing warning.
I've dealt with this in the past -- mine.
Hi, Sorry to ping, but some time has gone by -- I guess this fell through the cracks?
(In reply to Giuseppe D'Angelo from comment #3) > Hi, > > Sorry to ping, but some time has gone by -- I guess this fell through the > cracks? Yes, it did. Sorry. :-(
No problem, thanks for working on GCC :)