* [Bug c++/25137] Warning "missing braces around initializer" causing problems with tr1::array
2005-11-28 14:30 [Bug c++/25137] New: Warning "missing braces around initializer" causing problems with tr1::array chris at bubblescope dot net
@ 2005-11-28 14:52 ` pinskia at gcc dot gnu dot org
2005-11-28 15:17 ` chris at bubblescope dot net
` (9 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-11-28 14:52 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from pinskia at gcc dot gnu dot org 2005-11-28 14:52 -------
I don't see why the warning is not useful at all, in fact I rather have the C++
standard fix their wording of TR1's array.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25137
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/25137] Warning "missing braces around initializer" causing problems with tr1::array
2005-11-28 14:30 [Bug c++/25137] New: Warning "missing braces around initializer" causing problems with tr1::array chris at bubblescope dot net
2005-11-28 14:52 ` [Bug c++/25137] " pinskia at gcc dot gnu dot org
@ 2005-11-28 15:17 ` chris at bubblescope dot net
2005-11-28 16:15 ` gdr at integrable-solutions dot net
` (8 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: chris at bubblescope dot net @ 2005-11-28 15:17 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from chris at bubblescope dot net 2005-11-28 15:17 -------
Thats an option too, but I thought I'd see about gcc's opinion first, as I
expected a much faster reply than I would get from the C++ steering committee
:)
I find the warning helpful for constructs like:
struct S { int x[3]; int y[3]; }, or struct T {int x; S s;}; and such things, I
felt it was less useful for a single array inside a struct.
I'm guessing one of the major reasons that it would be nice to keep the style:
array<int,3> s = {1,2,3};
is to make it look as possible like:
int s[3] = {1,2,3};
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25137
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/25137] Warning "missing braces around initializer" causing problems with tr1::array
2005-11-28 14:30 [Bug c++/25137] New: Warning "missing braces around initializer" causing problems with tr1::array chris at bubblescope dot net
2005-11-28 14:52 ` [Bug c++/25137] " pinskia at gcc dot gnu dot org
2005-11-28 15:17 ` chris at bubblescope dot net
@ 2005-11-28 16:15 ` gdr at integrable-solutions dot net
2005-11-28 16:18 ` gdr at integrable-solutions dot net
` (7 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: gdr at integrable-solutions dot net @ 2005-11-28 16:15 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from gdr at integrable-solutions dot net 2005-11-28 16:15 -------
Subject: Re: Warning "missing braces around initializer" causing problems with
tr1::array
"pinskia at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org> writes:
| I don't see why the warning is not useful at all, in fact I rather
| have the C++ standard fix their wording of TR1's array.
it is not the C++ standard; but definitely a bug in the specification.
he problem shoul dbe reported there.
-- Gaby
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25137
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/25137] Warning "missing braces around initializer" causing problems with tr1::array
2005-11-28 14:30 [Bug c++/25137] New: Warning "missing braces around initializer" causing problems with tr1::array chris at bubblescope dot net
` (2 preceding siblings ...)
2005-11-28 16:15 ` gdr at integrable-solutions dot net
@ 2005-11-28 16:18 ` gdr at integrable-solutions dot net
2005-11-28 16:28 ` chris at bubblescope dot net
` (6 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: gdr at integrable-solutions dot net @ 2005-11-28 16:18 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from gdr at integrable-solutions dot net 2005-11-28 16:18 -------
Subject: Re: New: Warning "missing braces around initializer" causing
problems with tr1::array
"chris at bubblescope dot net" <gcc-bugzilla@gcc.gnu.org> writes:
| The following code:
|
| struct S
| { int x[3]; };
|
| void f()
| { S s = {1,2,3};}
|
| With -Wmissing-braces (which is implied by -Wall, among others) gives:
|
| warning: missing braces around initializer for 'int [3]'
|
| In the specific case where a struct contains only a single array, adding the
| extra braces doesn't really seem that useful.
|
| The reason it would be nice to fix this that in the definition of tr1::array
in
| the TR1 specification (page 88, 6.2.2) says
|
| 2.An array is an aggregate ([dcl.init.aggr]) that can be initialized with the
| syntax
| array a = { initializer-list };
I believe there is a slight confusion between a "C-array" and a TR1
class-type called "array". You have found a bug in the TR1; would you
mind making a report?
-- Gaby
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25137
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/25137] Warning "missing braces around initializer" causing problems with tr1::array
2005-11-28 14:30 [Bug c++/25137] New: Warning "missing braces around initializer" causing problems with tr1::array chris at bubblescope dot net
` (3 preceding siblings ...)
2005-11-28 16:18 ` gdr at integrable-solutions dot net
@ 2005-11-28 16:28 ` chris at bubblescope dot net
2005-11-28 16:33 ` chris at bubblescope dot net
` (5 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: chris at bubblescope dot net @ 2005-11-28 16:28 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from chris at bubblescope dot net 2005-11-28 16:28 -------
I'll make a report. Don't worry, I'm clear on the difference between tr1::array
and a C array, I just wanted to check that we agree this should produce a
warning (in which case I will go through the tr1::array testcases, and add the
extra pair of {})
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25137
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/25137] Warning "missing braces around initializer" causing problems with tr1::array
2005-11-28 14:30 [Bug c++/25137] New: Warning "missing braces around initializer" causing problems with tr1::array chris at bubblescope dot net
` (4 preceding siblings ...)
2005-11-28 16:28 ` chris at bubblescope dot net
@ 2005-11-28 16:33 ` chris at bubblescope dot net
2005-11-28 18:46 ` gdr at integrable-solutions dot net
` (4 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: chris at bubblescope dot net @ 2005-11-28 16:33 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from chris at bubblescope dot net 2005-11-28 16:33 -------
Actually, is a report really approriate? Writing array<int,3> = {1,2,3} is
perfectly valid C++, just warned about with -Wmissing-braces
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25137
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/25137] Warning "missing braces around initializer" causing problems with tr1::array
2005-11-28 14:30 [Bug c++/25137] New: Warning "missing braces around initializer" causing problems with tr1::array chris at bubblescope dot net
` (5 preceding siblings ...)
2005-11-28 16:33 ` chris at bubblescope dot net
@ 2005-11-28 18:46 ` gdr at integrable-solutions dot net
2005-12-04 5:04 ` gdr at gcc dot gnu dot org
` (3 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: gdr at integrable-solutions dot net @ 2005-11-28 18:46 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from gdr at integrable-solutions dot net 2005-11-28 18:46 -------
Subject: Re: Warning "missing braces around initializer" causing problems with
tr1::array
"chris at bubblescope dot net" <gcc-bugzilla@gcc.gnu.org> writes:
| Actually, is a report really approriate? Writing array<int,3> = {1,2,3} is
| perfectly valid C++, just warned about with -Wmissing-braces
You're absolutely right! I forgot 8.5.1/11!
Can't we have simple, general rules, without list of special cases? :-(
-- Gaby
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25137
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/25137] Warning "missing braces around initializer" causing problems with tr1::array
2005-11-28 14:30 [Bug c++/25137] New: Warning "missing braces around initializer" causing problems with tr1::array chris at bubblescope dot net
` (6 preceding siblings ...)
2005-11-28 18:46 ` gdr at integrable-solutions dot net
@ 2005-12-04 5:04 ` gdr at gcc dot gnu dot org
2005-12-06 13:07 ` gcc-bugzilla at kayari dot org
` (2 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: gdr at gcc dot gnu dot org @ 2005-12-04 5:04 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from gdr at gcc dot gnu dot org 2005-12-04 05:04 -------
(In reply to comment #0)
> The following code:
>
> struct S
> { int x[3]; };
>
> void f()
> { S s = {1,2,3};}
>
> With -Wmissing-braces (which is implied by -Wall, among others) gives:
>
> warning: missing braces around initializer for 'int [3]'
>
> In the specific case where a struct contains only a single array, adding the
> extra braces doesn't really seem that useful.
>
> The reason it would be nice to fix this that in the definition of tr1::array in
> the TR1 specification (page 88, 6.2.2) says
After more thoughts on this issue, it appears to me that it is asking for
a special casing justforo tr1::array<> to work. I don't know whether
that is a workable approach. I would reommend -Wno-missing-braces in this
specific case. Thoughts?
--
gdr at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |gdr at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25137
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/25137] Warning "missing braces around initializer" causing problems with tr1::array
2005-11-28 14:30 [Bug c++/25137] New: Warning "missing braces around initializer" causing problems with tr1::array chris at bubblescope dot net
` (7 preceding siblings ...)
2005-12-04 5:04 ` gdr at gcc dot gnu dot org
@ 2005-12-06 13:07 ` gcc-bugzilla at kayari dot org
2006-04-04 5:44 ` pinskia at gcc dot gnu dot org
2007-09-21 16:50 ` pcarlini at suse dot de
10 siblings, 0 replies; 12+ messages in thread
From: gcc-bugzilla at kayari dot org @ 2005-12-06 13:07 UTC (permalink / raw)
To: gcc-bugs
------- 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
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/25137] Warning "missing braces around initializer" causing problems with tr1::array
2005-11-28 14:30 [Bug c++/25137] New: Warning "missing braces around initializer" causing problems with tr1::array chris at bubblescope dot net
` (8 preceding siblings ...)
2005-12-06 13:07 ` gcc-bugzilla at kayari dot org
@ 2006-04-04 5:44 ` pinskia at gcc dot gnu dot org
2007-09-21 16:50 ` pcarlini at suse dot de
10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-04-04 5:44 UTC (permalink / raw)
To: gcc-bugs
------- Comment #10 from pinskia at gcc dot gnu dot org 2006-04-04 05:44 -------
*** Bug 27015 has been marked as a duplicate of this bug. ***
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |lidaobing at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25137
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/25137] Warning "missing braces around initializer" causing problems with tr1::array
2005-11-28 14:30 [Bug c++/25137] New: Warning "missing braces around initializer" causing problems with tr1::array chris at bubblescope dot net
` (9 preceding siblings ...)
2006-04-04 5:44 ` pinskia at gcc dot gnu dot org
@ 2007-09-21 16:50 ` pcarlini at suse dot de
10 siblings, 0 replies; 12+ messages in thread
From: pcarlini at suse dot de @ 2007-09-21 16:50 UTC (permalink / raw)
To: gcc-bugs
------- Comment #11 from pcarlini at suse dot de 2007-09-21 16:50 -------
Looking into it: I mean to investigate whether a relaxed warning per Comment #9
is implementable in a decently clean way.
--
pcarlini at suse dot de changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |pcarlini at suse dot de
|dot org |
Status|UNCONFIRMED |ASSIGNED
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2007-09-21 16:50:22
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25137
^ permalink raw reply [flat|nested] 12+ messages in thread