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

--- Comment #7 from Will Wray <wjwray at gmail dot com> ---
I guess that the bug persisted so long *because* of the status quo;
portable code had to delete extra braces to silence warnings or to compile
i.e. the warning on Clang served the purpose of promoting portability to GCC.

So, as to whether it should be a warning; I think not, but...
for practical portability reasons, it probably should be left as a warning
at least until some epoch like C++2a where both GCC & Clang could remove
the warning under the -std=c++2a flag. Make sense?

FYI My use case is counting aggregate members, similar to fields_count
in boost/pfr 'magic_get', but extended to support array members:

https://github.com/apolukhin/magic_get/blob/develop/include/boost/pfr/detail/fields_count.hpp

That code initializes an aggregate T from an index_sequence I... as
    T{ ubiq{I}... }   (where ubiq is a 'convert to anything' type)

To support 'skipping' arrays, you want to initialize the aggregate as
    T{ {ubiq{I}}...}

but, for scalar members, this is what currently fails on GCC / warns on Clang.

Another reason that the bug persisted is the general confusion around braces
and uniform initialization - this fix will give a generic, uniform, way to
initialize the leading members of an aggregate.

I wonder if the extra braces should have additional benefits like not allowing
narrowing conversions. My limited experiments (on Clang) show no difference.

Reply via email to