This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/25137] Warning "missing braces around initializer" causing problems with tr1::array



------- Comment #9 from gcc-bugzilla at kayari dot org  2005-12-06 13:07 -------
I've often found this warning to be a nuisance, because it's correct and
well-defined to omit some braces from the initializer.

There are many cases where the warning is useful, e.g. with aggregates that
have several members (which may be aggregates themselves), but when the type
contains a single member (possibly of array type) then the extra braces are
often just clutter.

Pff the top of my head, I would like a way to disable the warning iff the
aggregate has a single member and iff the initializer contains exactly the
right number of elements to initialize that single member.  e.g.

struct S { int s[3]; };
S s1 = { 1, 1, 1 };       // OK   - missing braces but correct number
S s2 = { 1, 1 };          // WARN - no initializer for s2.s[2]
S s3 = { { 1, 1 } };      // OK   - braces correct but missing init

I don't think this would be useful only for tr1::array, but for lots of similar
code.  Obvious and closely-related examples are the block and carray templates
in Austern and Josuttis's books.


-- 

gcc-bugzilla at kayari dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |gcc-bugzilla at kayari dot
                   |                            |org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25137


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]