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

2012-05-29 Thread manu at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25137

Manuel López-Ibáñez manu at gcc dot gnu.org changed:

   What|Removed |Added

 CC||manu at gcc dot gnu.org

--- Comment #21 from Manuel López-Ibáñez manu at gcc dot gnu.org 2012-05-29 
08:03:07 UTC ---
Hi Paolo (cc. Jason),

for options that enable other options only in specific languages, it would be
good to use the new LangEnabledBy in the .opt files. (For example, this will
make -Wno-missing-braces -Wall work as expected).


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

2012-05-29 Thread paolo.carlini at oracle dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25137

--- Comment #22 from Paolo Carlini paolo.carlini at oracle dot com 2012-05-29 
09:05:51 UTC ---
Oops, sorry, I think at some point I wondered if something was in order but
then forgot. If you can tell me the right syntax, I can add it, must be quite
simple, right?


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

2012-05-29 Thread manu at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25137

--- Comment #23 from Manuel López-Ibáñez manu at gcc dot gnu.org 2012-05-29 
09:22:05 UTC ---
It is explained here
http://gcc.gnu.org/onlinedocs/gccint/Option-properties.html#Option-properties

A patch like the following should work (plus removing the special handling in
c-opts.c)

Index: c.opt
===
--- c.opt(revision 187628)
+++ c.opt(working copy)
@@ -463,7 +463,7 @@
 Warn about suspicious declarations of \main\

 Wmissing-braces
-C ObjC C++ ObjC++ Var(warn_missing_braces) Warning
+C ObjC C++ ObjC++ Var(warn_missing_braces) Warning LangEnabledBy(C ObjC, Wall)
 Warn about possibly missing braces around initializers


There is also EnabledBy, which is unconditional. The plan is to convert
sub-options to use this infrastructure. There is also some functionality
missing:

* An option enabled only if two options are combined. (-Wextra  -Wunused
enable -Wunused-parameter).

* An option enabled by some arbitrary condition.

And some options are problematic because they currently have bugs: warn_format
is 0 by default but the value of -Wformat in the gcc_opts structure is -1, thus
calling warning(OPT_Wformat) without checking warn_format means enabled by
default. Some tests expect such diagnostics to be enabled by default. :-(


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

2012-05-29 Thread paolo.carlini at oracle dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25137

--- Comment #24 from Paolo Carlini paolo.carlini at oracle dot com 2012-05-29 
09:41:01 UTC ---
Thanks. I'm going to test the patchlet momentarily, I think it qualifies as
obvious.


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

2012-05-28 Thread paolo at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25137

--- Comment #19 from paolo at gcc dot gnu.org paolo at gcc dot gnu.org 
2012-05-28 17:42:34 UTC ---
Author: paolo
Date: Mon May 28 17:42:29 2012
New Revision: 187937

URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=187937
Log:
/c-family
2012-05-28  Paolo Carlini  paolo.carl...@oracle.com

PR c++/25137
* c-opts.c (c_common_handle_option): For C++ -Wall doesn't enable
-Wmissing_braces.

2012-05-28  Paolo Carlini  paolo.carl...@oracle.com

PR c++/25137
* doc/invoke.texi: Document -Wmissing-braces not enabled by -Wall
for C++.

/testsuite
2012-05-28  Paolo Carlini  paolo.carl...@oracle.com

PR c++/25137
* g++.dg/warn/Wbraces3.C: New.
* g++.dg/warn/Wbraces4.C: Likewise.

Added:
trunk/gcc/testsuite/g++.dg/warn/Wbraces3.C
trunk/gcc/testsuite/g++.dg/warn/Wbraces4.C
Modified:
trunk/gcc/ChangeLog
trunk/gcc/c-family/ChangeLog
trunk/gcc/c-family/c-opts.c
trunk/gcc/doc/invoke.texi
trunk/gcc/testsuite/ChangeLog


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

2012-05-28 Thread paolo.carlini at oracle dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25137

Paolo Carlini paolo.carlini at oracle dot com changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution||FIXED

--- Comment #19 from paolo at gcc dot gnu.org paolo at gcc dot gnu.org 
2012-05-28 17:42:34 UTC ---
Author: paolo
Date: Mon May 28 17:42:29 2012
New Revision: 187937

URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=187937
Log:
/c-family
2012-05-28  Paolo Carlini  paolo.carl...@oracle.com

PR c++/25137
* c-opts.c (c_common_handle_option): For C++ -Wall doesn't enable
-Wmissing_braces.

2012-05-28  Paolo Carlini  paolo.carl...@oracle.com

PR c++/25137
* doc/invoke.texi: Document -Wmissing-braces not enabled by -Wall
for C++.

/testsuite
2012-05-28  Paolo Carlini  paolo.carl...@oracle.com

PR c++/25137
* g++.dg/warn/Wbraces3.C: New.
* g++.dg/warn/Wbraces4.C: Likewise.

Added:
trunk/gcc/testsuite/g++.dg/warn/Wbraces3.C
trunk/gcc/testsuite/g++.dg/warn/Wbraces4.C
Modified:
trunk/gcc/ChangeLog
trunk/gcc/c-family/ChangeLog
trunk/gcc/c-family/c-opts.c
trunk/gcc/doc/invoke.texi
trunk/gcc/testsuite/ChangeLog

--- Comment #20 from Paolo Carlini paolo.carlini at oracle dot com 2012-05-28 
17:44:52 UTC ---
Done.


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

2012-05-28 Thread paolo at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25137

Paolo Carlini paolo.carlini at oracle dot com changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution||FIXED

--- Comment #20 from Paolo Carlini paolo.carlini at oracle dot com 2012-05-28 
17:44:52 UTC ---
Done.


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

2012-05-26 Thread jason at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25137

Jason Merrill jason at gcc dot gnu.org changed:

   What|Removed |Added

 CC||jason at gcc dot gnu.org

--- Comment #17 from Jason Merrill jason at gcc dot gnu.org 2012-05-26 
21:21:51 UTC ---
Hmm.  I see the argument, but it seems to me that the purpose of
-Wmissing-braces is precisely to warn about this sort of thing.  Perhaps it
just shouldn't be part of -Wall in C++ mode, particularly in C++11 since
initializer lists are a lot more flexible now.


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

2012-05-26 Thread paolo.carlini at oracle dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25137

Paolo Carlini paolo.carlini at oracle dot com changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
 AssignedTo|unassigned at gcc dot   |paolo.carlini at oracle dot
   |gnu.org |com
   Target Milestone|--- |4.8.0

--- Comment #18 from Paolo Carlini paolo.carlini at oracle dot com 2012-05-26 
21:46:03 UTC ---
Let's take it out of C++ then.


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

2011-08-30 Thread paolo.carlini at oracle dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25137

Paolo Carlini paolo.carlini at oracle dot com changed:

   What|Removed |Added

 CC||dodji at gcc dot gnu.org

--- Comment #16 from Paolo Carlini paolo.carlini at oracle dot com 2011-08-30 
09:41:23 UTC ---
Maybe Dodji is interested in working on this?!? Can be quite annoying with
tr1::array and std::array in C++11, of course.


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

2011-08-27 Thread baffo32 at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25137

baffo32 at gmail dot com changed:

   What|Removed |Added

 CC||baffo32 at gmail dot com

--- Comment #15 from baffo32 at gmail dot com 2011-08-27 08:53:59 UTC ---
(In reply to comment #13)
 GCC allows it too, otherwise it would be an error not a warning.

I believe GCC fails for multi-dimensional arrays?

arrayarrayint,2,2 a{ {1,2},{3,4} }; // won't compile without another pair
of {}


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

2010-12-17 Thread bitti at iki dot fi
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25137

Matti Rintala bitti at iki dot fi changed:

   What|Removed |Added

 CC||bitti at iki dot fi

--- Comment #12 from Matti Rintala bitti at iki dot fi 2010-12-17 11:21:06 
UTC ---
Has there been any progress with this bug/problem? The latest C++0x draft still
explicitly allows array aT, N = { initializer-list }; (23.3.1/2), but at
least gcc 4.5.1 still gives a warning with -Wall enabled.


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

2010-12-17 Thread paolo.carlini at oracle dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25137

Paolo Carlini paolo.carlini at oracle dot com changed:

   What|Removed |Added

 Status|ASSIGNED|NEW
 AssignedTo|paolo.carlini at oracle dot |unassigned at gcc dot
   |com |gnu.org


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

2010-12-17 Thread redi at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25137

--- Comment #13 from Jonathan Wakely redi at gcc dot gnu.org 2010-12-17 
11:33:48 UTC ---
GCC allows it too, otherwise it would be an error not a warning.

But no, there hasn't been any progress I know of, the warning is still given
for std::array in C++0x mode as well as tr1::array


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

2010-12-17 Thread paolo.carlini at oracle dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25137

--- Comment #14 from Paolo Carlini paolo.carlini at oracle dot com 2010-12-17 
12:22:50 UTC ---
I'm sorry I don't mean to wrk on this over the next weeks, maybe sombody will
ne interested in picking my patch in this thread and completing it (both for C
and C++): http://gcc.gnu.org/ml/gcc/2009-11/msg00430.html
http://gcc.gnu.org/ml/gcc/2009-11/msg00468.html


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

2007-09-21 Thread pcarlini at suse dot de


--- 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|-00-00 00:00:00 |2007-09-21 16:50:22
   date||


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



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

2006-04-03 Thread pinskia at gcc dot gnu dot org


--- 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



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

2005-12-06 Thread gcc-bugzilla at kayari dot org


--- 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



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

2005-12-03 Thread gdr at gcc dot gnu dot org


--- 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



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

2005-11-28 Thread pinskia at gcc dot gnu dot org


--- 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



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

2005-11-28 Thread chris at bubblescope dot net


--- 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:

arrayint,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



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

2005-11-28 Thread gdr at integrable-solutions dot net


--- 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 [EMAIL PROTECTED] 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



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

2005-11-28 Thread gdr at integrable-solutions dot net


--- 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 [EMAIL PROTECTED] 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



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

2005-11-28 Thread chris at bubblescope dot net


--- 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



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

2005-11-28 Thread chris at bubblescope dot net


--- Comment #6 from chris at bubblescope dot net  2005-11-28 16:33 ---
Actually, is a report really approriate? Writing arrayint,3 = {1,2,3} is
perfectly valid C++, just warned about with -Wmissing-braces


-- 


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



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

2005-11-28 Thread gdr at integrable-solutions dot net


--- 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 [EMAIL PROTECTED] writes:

| Actually, is a report really approriate? Writing arrayint,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