public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/25137] Warning "missing braces around initializer" causing problems with tr1::array
       [not found] <bug-25137-4@http.gcc.gnu.org/bugzilla/>
@ 2010-12-17 11:21 ` bitti at iki dot fi
  2010-12-17 11:27 ` paolo.carlini at oracle dot com
                   ` (13 subsequent siblings)
  14 siblings, 0 replies; 26+ messages in thread
From: bitti at iki dot fi @ 2010-12-17 11:21 UTC (permalink / raw)
  To: gcc-bugs

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 a<T, N> = { initializer-list };" (23.3.1/2), but at
least gcc 4.5.1 still gives a warning with -Wall enabled.


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [Bug c++/25137] Warning "missing braces around initializer" causing problems with tr1::array
       [not found] <bug-25137-4@http.gcc.gnu.org/bugzilla/>
  2010-12-17 11:21 ` [Bug c++/25137] Warning "missing braces around initializer" causing problems with tr1::array bitti at iki dot fi
@ 2010-12-17 11:27 ` paolo.carlini at oracle dot com
  2010-12-17 11:34 ` redi at gcc dot gnu.org
                   ` (12 subsequent siblings)
  14 siblings, 0 replies; 26+ messages in thread
From: paolo.carlini at oracle dot com @ 2010-12-17 11:27 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [Bug c++/25137] Warning "missing braces around initializer" causing problems with tr1::array
       [not found] <bug-25137-4@http.gcc.gnu.org/bugzilla/>
  2010-12-17 11:21 ` [Bug c++/25137] Warning "missing braces around initializer" causing problems with tr1::array bitti at iki dot fi
  2010-12-17 11:27 ` paolo.carlini at oracle dot com
@ 2010-12-17 11:34 ` redi at gcc dot gnu.org
  2010-12-17 12:23 ` paolo.carlini at oracle dot com
                   ` (11 subsequent siblings)
  14 siblings, 0 replies; 26+ messages in thread
From: redi at gcc dot gnu.org @ 2010-12-17 11:34 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [Bug c++/25137] Warning "missing braces around initializer" causing problems with tr1::array
       [not found] <bug-25137-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2010-12-17 11:34 ` redi at gcc dot gnu.org
@ 2010-12-17 12:23 ` paolo.carlini at oracle dot com
  2011-08-27  9:23 ` baffo32 at gmail dot com
                   ` (10 subsequent siblings)
  14 siblings, 0 replies; 26+ messages in thread
From: paolo.carlini at oracle dot com @ 2010-12-17 12:23 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [Bug c++/25137] Warning "missing braces around initializer" causing problems with tr1::array
       [not found] <bug-25137-4@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2010-12-17 12:23 ` paolo.carlini at oracle dot com
@ 2011-08-27  9:23 ` baffo32 at gmail dot com
  2011-08-30 10:29 ` paolo.carlini at oracle dot com
                   ` (9 subsequent siblings)
  14 siblings, 0 replies; 26+ messages in thread
From: baffo32 at gmail dot com @ 2011-08-27  9:23 UTC (permalink / raw)
  To: gcc-bugs

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?

array<array<int,2>,2> a{ {1,2},{3,4} }; // won't compile without another pair
of {}


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [Bug c++/25137] Warning "missing braces around initializer" causing problems with tr1::array
       [not found] <bug-25137-4@http.gcc.gnu.org/bugzilla/>
                   ` (4 preceding siblings ...)
  2011-08-27  9:23 ` baffo32 at gmail dot com
@ 2011-08-30 10:29 ` paolo.carlini at oracle dot com
  2012-05-26 21:24 ` jason at gcc dot gnu.org
                   ` (8 subsequent siblings)
  14 siblings, 0 replies; 26+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-08-30 10:29 UTC (permalink / raw)
  To: gcc-bugs

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.


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [Bug c++/25137] Warning "missing braces around initializer" causing problems with tr1::array
       [not found] <bug-25137-4@http.gcc.gnu.org/bugzilla/>
                   ` (5 preceding siblings ...)
  2011-08-30 10:29 ` paolo.carlini at oracle dot com
@ 2012-05-26 21:24 ` jason at gcc dot gnu.org
  2012-05-26 22:38 ` paolo.carlini at oracle dot com
                   ` (7 subsequent siblings)
  14 siblings, 0 replies; 26+ messages in thread
From: jason at gcc dot gnu.org @ 2012-05-26 21:24 UTC (permalink / raw)
  To: gcc-bugs

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.


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [Bug c++/25137] Warning "missing braces around initializer" causing problems with tr1::array
       [not found] <bug-25137-4@http.gcc.gnu.org/bugzilla/>
                   ` (6 preceding siblings ...)
  2012-05-26 21:24 ` jason at gcc dot gnu.org
@ 2012-05-26 22:38 ` paolo.carlini at oracle dot com
  2012-05-28 17:46 ` paolo at gcc dot gnu.org
                   ` (6 subsequent siblings)
  14 siblings, 0 replies; 26+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-05-26 22:38 UTC (permalink / raw)
  To: gcc-bugs

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.


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [Bug c++/25137] Warning "missing braces around initializer" causing problems with tr1::array
       [not found] <bug-25137-4@http.gcc.gnu.org/bugzilla/>
                   ` (8 preceding siblings ...)
  2012-05-28 17:46 ` paolo at gcc dot gnu.org
@ 2012-05-28 17:46 ` paolo.carlini at oracle dot com
  2012-05-28 18:35 ` paolo at gcc dot gnu.org
                   ` (4 subsequent siblings)
  14 siblings, 0 replies; 26+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-05-28 17:46 UTC (permalink / raw)
  To: gcc-bugs

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=gcc&view=rev&rev=187937
Log:
/c-family
2012-05-28  Paolo Carlini  <paolo.carlini@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.carlini@oracle.com>

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

/testsuite
2012-05-28  Paolo Carlini  <paolo.carlini@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.


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [Bug c++/25137] Warning "missing braces around initializer" causing problems with tr1::array
       [not found] <bug-25137-4@http.gcc.gnu.org/bugzilla/>
                   ` (7 preceding siblings ...)
  2012-05-26 22:38 ` paolo.carlini at oracle dot com
@ 2012-05-28 17:46 ` paolo at gcc dot gnu.org
  2012-05-28 17:46 ` paolo.carlini at oracle dot com
                   ` (5 subsequent siblings)
  14 siblings, 0 replies; 26+ messages in thread
From: paolo at gcc dot gnu.org @ 2012-05-28 17:46 UTC (permalink / raw)
  To: gcc-bugs

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=gcc&view=rev&rev=187937
Log:
/c-family
2012-05-28  Paolo Carlini  <paolo.carlini@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.carlini@oracle.com>

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

/testsuite
2012-05-28  Paolo Carlini  <paolo.carlini@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


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [Bug c++/25137] Warning "missing braces around initializer" causing problems with tr1::array
       [not found] <bug-25137-4@http.gcc.gnu.org/bugzilla/>
                   ` (9 preceding siblings ...)
  2012-05-28 17:46 ` paolo.carlini at oracle dot com
@ 2012-05-28 18:35 ` paolo at gcc dot gnu.org
  2012-05-29  8:09 ` manu at gcc dot gnu.org
                   ` (3 subsequent siblings)
  14 siblings, 0 replies; 26+ messages in thread
From: paolo at gcc dot gnu.org @ 2012-05-28 18:35 UTC (permalink / raw)
  To: gcc-bugs

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.


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [Bug c++/25137] Warning "missing braces around initializer" causing problems with tr1::array
       [not found] <bug-25137-4@http.gcc.gnu.org/bugzilla/>
                   ` (10 preceding siblings ...)
  2012-05-28 18:35 ` paolo at gcc dot gnu.org
@ 2012-05-29  8:09 ` manu at gcc dot gnu.org
  2012-05-29  9:27 ` paolo.carlini at oracle dot com
                   ` (2 subsequent siblings)
  14 siblings, 0 replies; 26+ messages in thread
From: manu at gcc dot gnu.org @ 2012-05-29  8:09 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [Bug c++/25137] Warning "missing braces around initializer" causing problems with tr1::array
       [not found] <bug-25137-4@http.gcc.gnu.org/bugzilla/>
                   ` (11 preceding siblings ...)
  2012-05-29  8:09 ` manu at gcc dot gnu.org
@ 2012-05-29  9:27 ` paolo.carlini at oracle dot com
  2012-05-29  9:28 ` manu at gcc dot gnu.org
  2012-05-29  9:43 ` paolo.carlini at oracle dot com
  14 siblings, 0 replies; 26+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-05-29  9:27 UTC (permalink / raw)
  To: gcc-bugs

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?


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [Bug c++/25137] Warning "missing braces around initializer" causing problems with tr1::array
       [not found] <bug-25137-4@http.gcc.gnu.org/bugzilla/>
                   ` (12 preceding siblings ...)
  2012-05-29  9:27 ` paolo.carlini at oracle dot com
@ 2012-05-29  9:28 ` manu at gcc dot gnu.org
  2012-05-29  9:43 ` paolo.carlini at oracle dot com
  14 siblings, 0 replies; 26+ messages in thread
From: manu at gcc dot gnu.org @ 2012-05-29  9:28 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [Bug c++/25137] Warning "missing braces around initializer" causing problems with tr1::array
       [not found] <bug-25137-4@http.gcc.gnu.org/bugzilla/>
                   ` (13 preceding siblings ...)
  2012-05-29  9:28 ` manu at gcc dot gnu.org
@ 2012-05-29  9:43 ` paolo.carlini at oracle dot com
  14 siblings, 0 replies; 26+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-05-29  9:43 UTC (permalink / raw)
  To: gcc-bugs

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.


^ permalink raw reply	[flat|nested] 26+ 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: " 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; 26+ 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] 26+ 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: " 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; 26+ 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] 26+ 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: " 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; 26+ 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] 26+ 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: " 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; 26+ 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] 26+ 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: " 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; 26+ 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] 26+ 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: " 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; 26+ 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] 26+ 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: " 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; 26+ 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] 26+ 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: " 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; 26+ 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] 26+ 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: " 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; 26+ 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] 26+ 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: " 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; 26+ 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] 26+ 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: " 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; 26+ 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] 26+ messages in thread

end of thread, other threads:[~2012-05-29  9:42 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-25137-4@http.gcc.gnu.org/bugzilla/>
2010-12-17 11:21 ` [Bug c++/25137] Warning "missing braces around initializer" causing problems with tr1::array bitti at iki dot fi
2010-12-17 11:27 ` paolo.carlini at oracle dot com
2010-12-17 11:34 ` redi at gcc dot gnu.org
2010-12-17 12:23 ` paolo.carlini at oracle dot com
2011-08-27  9:23 ` baffo32 at gmail dot com
2011-08-30 10:29 ` paolo.carlini at oracle dot com
2012-05-26 21:24 ` jason at gcc dot gnu.org
2012-05-26 22:38 ` paolo.carlini at oracle dot com
2012-05-28 17:46 ` paolo at gcc dot gnu.org
2012-05-28 17:46 ` paolo.carlini at oracle dot com
2012-05-28 18:35 ` paolo at gcc dot gnu.org
2012-05-29  8:09 ` manu at gcc dot gnu.org
2012-05-29  9:27 ` paolo.carlini at oracle dot com
2012-05-29  9:28 ` manu at gcc dot gnu.org
2012-05-29  9:43 ` paolo.carlini at oracle dot com
2005-11-28 14:30 [Bug c++/25137] New: " 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
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
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).