public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/20175] New: Warnings are issued when initializing struct members with "strings"
@ 2005-02-23 20:58 gcc at magfr dot user dot lysator dot liu dot se
  2005-02-23 21:03 ` [Bug c++/20175] " gcc at magfr dot user dot lysator dot liu dot se
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: gcc at magfr dot user dot lysator dot liu dot se @ 2005-02-23 20:58 UTC (permalink / raw)
  To: gcc-bugs

When compiling the attached file foo.C using the flag -Wmissing-braces (part of
-Wall) then the warning

foo.C:3: warning: missing braces around initializer

is printed even though no braces are needed around the char array.

-- 
           Summary: Warnings are issued when initializing struct members
                    with "strings"
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: gcc at magfr dot user dot lysator dot liu dot se
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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


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

* [Bug c++/20175] Warnings are issued when initializing struct members with "strings"
  2005-02-23 20:58 [Bug c++/20175] New: Warnings are issued when initializing struct members with "strings" gcc at magfr dot user dot lysator dot liu dot se
@ 2005-02-23 21:03 ` gcc at magfr dot user dot lysator dot liu dot se
  2005-02-23 22:21 ` [Bug c++/20175] [3.4/4.0 Regression] " pinskia at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: gcc at magfr dot user dot lysator dot liu dot se @ 2005-02-23 21:03 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From gcc at magfr dot user dot lysator dot liu dot se  2005-02-23 18:15 -------
Created an attachment (id=8267)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=8267&action=view)
Program demonstrating the bug

Compile with

g++ -Wmissing-braces -c foo.C

to demonstrate the bug.

-- 


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


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

* [Bug c++/20175] [3.4/4.0 Regression] Warnings are issued when initializing struct members with "strings"
  2005-02-23 20:58 [Bug c++/20175] New: Warnings are issued when initializing struct members with "strings" gcc at magfr dot user dot lysator dot liu dot se
  2005-02-23 21:03 ` [Bug c++/20175] " gcc at magfr dot user dot lysator dot liu dot se
@ 2005-02-23 22:21 ` pinskia at gcc dot gnu dot org
  2005-02-24 15:46 ` jakub at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-02-23 22:21 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-02-23 18:27 -------
Confirmed, this was introduced  (most likely when the patch to fix for PR 19755 was committed).
Reduced testcase:
struct c { char s[8]; int i;};

struct c a = {"hello", 1};

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mmitchel at gcc dot gnu dot
                   |                            |org
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
           Keywords|                            |diagnostic
   Last reconfirmed|0000-00-00 00:00:00         |2005-02-23 18:27:26
               date|                            |
            Summary|Warnings are issued when    |[3.4/4.0 Regression]
                   |initializing struct members |Warnings are issued when
                   |with "strings"              |initializing struct members
                   |                            |with "strings"
   Target Milestone|---                         |3.4.4


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


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

* [Bug c++/20175] [3.4/4.0 Regression] Warnings are issued when initializing struct members with "strings"
  2005-02-23 20:58 [Bug c++/20175] New: Warnings are issued when initializing struct members with "strings" gcc at magfr dot user dot lysator dot liu dot se
  2005-02-23 21:03 ` [Bug c++/20175] " gcc at magfr dot user dot lysator dot liu dot se
  2005-02-23 22:21 ` [Bug c++/20175] [3.4/4.0 Regression] " pinskia at gcc dot gnu dot org
@ 2005-02-24 15:46 ` jakub at gcc dot gnu dot org
  2005-02-24 15:59 ` jakub at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu dot org @ 2005-02-24 15:46 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |jakub at gcc dot gnu dot org
                   |dot org                     |
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2005-02-23 18:27:26         |2005-02-24 11:44:57
               date|                            |


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


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

* [Bug c++/20175] [3.4/4.0 Regression] Warnings are issued when initializing struct members with "strings"
  2005-02-23 20:58 [Bug c++/20175] New: Warnings are issued when initializing struct members with "strings" gcc at magfr dot user dot lysator dot liu dot se
                   ` (2 preceding siblings ...)
  2005-02-24 15:46 ` jakub at gcc dot gnu dot org
@ 2005-02-24 15:59 ` jakub at gcc dot gnu dot org
  2005-02-25  1:49 ` cvs-commit at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu dot org @ 2005-02-24 15:59 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From jakub at gcc dot gnu dot org  2005-02-24 12:34 -------
Patch here: <http://gcc.gnu.org/ml/gcc-patches/2005-02/msg01489.html>

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch


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


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

* [Bug c++/20175] [3.4/4.0 Regression] Warnings are issued when initializing struct members with "strings"
  2005-02-23 20:58 [Bug c++/20175] New: Warnings are issued when initializing struct members with "strings" gcc at magfr dot user dot lysator dot liu dot se
                   ` (3 preceding siblings ...)
  2005-02-24 15:59 ` jakub at gcc dot gnu dot org
@ 2005-02-25  1:49 ` cvs-commit at gcc dot gnu dot org
  2005-02-25  2:04 ` [Bug c++/20175] [3.4 " pinskia at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-02-25  1:49 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2005-02-24 21:21 -------
Subject: Bug 20175

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	jakub@gcc.gnu.org	2005-02-24 21:21:28

Modified files:
	gcc/cp         : ChangeLog 
	gcc/testsuite  : ChangeLog 
	gcc/cp         : decl.c 
Added files:
	gcc/testsuite/g++.dg/warn: Wbraces2.C 

Log message:
	PR c++/20175
	* decl.c (reshape_init): Don't warn about missing braces if STRING_CST
	initializes a char/wchar_t array.
	
	* g++.dg/warn/Wbraces2.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4646&r2=1.4647
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.5082&r2=1.5083
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&r1=1.1370&r2=1.1371
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/warn/Wbraces2.C.diff?cvsroot=gcc&r1=NONE&r2=1.1



-- 


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


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

* [Bug c++/20175] [3.4 Regression] Warnings are issued when initializing struct members with "strings"
  2005-02-23 20:58 [Bug c++/20175] New: Warnings are issued when initializing struct members with "strings" gcc at magfr dot user dot lysator dot liu dot se
                   ` (4 preceding siblings ...)
  2005-02-25  1:49 ` cvs-commit at gcc dot gnu dot org
@ 2005-02-25  2:04 ` pinskia at gcc dot gnu dot org
  2005-02-25 19:47 ` gcc at magfr dot user dot lysator dot liu dot se
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-02-25  2:04 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-02-24 21:48 -------
Fixed on the mainline.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|                            |3.2.3 4.0.0
            Summary|[3.4/4.0 Regression]        |[3.4 Regression] Warnings
                   |Warnings are issued when    |are issued when initializing
                   |initializing struct members |struct members with
                   |with "strings"              |"strings"


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


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

* [Bug c++/20175] [3.4 Regression] Warnings are issued when initializing struct members with "strings"
  2005-02-23 20:58 [Bug c++/20175] New: Warnings are issued when initializing struct members with "strings" gcc at magfr dot user dot lysator dot liu dot se
                   ` (5 preceding siblings ...)
  2005-02-25  2:04 ` [Bug c++/20175] [3.4 " pinskia at gcc dot gnu dot org
@ 2005-02-25 19:47 ` gcc at magfr dot user dot lysator dot liu dot se
  2005-02-25 19:49 ` pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: gcc at magfr dot user dot lysator dot liu dot se @ 2005-02-25 19:47 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From gcc at magfr dot user dot lysator dot liu dot se  2005-02-25 14:55 -------
(In reply to comment #3)
> Patch here: <http://gcc.gnu.org/ml/gcc-patches/2005-02/msg01489.html>

This fixes the obvious case but it also makes the following pass with no
warnings and that is wrong, note especially S1 and S3!

struct S { char a[6]; int b[2]; };

S S0 = { { "hello" }, { 1, 2 } };
S S1 = { { "hello" }, 1, 2 }; // Highly suspicious
S S2 = { "hello", { 1, 2 } };
S S3 = { "hello", 1, 2 }; // Highly suspicious


-- 


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


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

* [Bug c++/20175] [3.4 Regression] Warnings are issued when initializing struct members with "strings"
  2005-02-23 20:58 [Bug c++/20175] New: Warnings are issued when initializing struct members with "strings" gcc at magfr dot user dot lysator dot liu dot se
                   ` (6 preceding siblings ...)
  2005-02-25 19:47 ` gcc at magfr dot user dot lysator dot liu dot se
@ 2005-02-25 19:49 ` pinskia at gcc dot gnu dot org
  2005-02-28  1:36 ` cvs-commit at gcc dot gnu dot org
  2005-02-28  1:42 ` jakub at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-02-25 19:49 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-02-25 15:02 -------
(In reply to comment #6)
> (In reply to comment #3)
> > Patch here: <http://gcc.gnu.org/ml/gcc-patches/2005-02/msg01489.html>
> 
> This fixes the obvious case but it also makes the following pass with no
> warnings and that is wrong, note especially S1 and S3!
That looks like a different bug, I am filing a new bug for this (PR 20209).

-- 


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


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

* [Bug c++/20175] [3.4 Regression] Warnings are issued when initializing struct members with "strings"
  2005-02-23 20:58 [Bug c++/20175] New: Warnings are issued when initializing struct members with "strings" gcc at magfr dot user dot lysator dot liu dot se
                   ` (7 preceding siblings ...)
  2005-02-25 19:49 ` pinskia at gcc dot gnu dot org
@ 2005-02-28  1:36 ` cvs-commit at gcc dot gnu dot org
  2005-02-28  1:42 ` jakub at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-02-28  1:36 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2005-02-27 18:11 -------
Subject: Bug 20175

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_4-branch
Changes by:	jakub@gcc.gnu.org	2005-02-27 18:10:42

Modified files:
	gcc/cp         : ChangeLog 
	gcc/testsuite  : ChangeLog 
	gcc/cp         : decl.c 
Added files:
	gcc/testsuite/g++.dg/warn: Wbraces2.C 

Log message:
	PR c++/20175
	* decl.c (reshape_init): Don't warn about missing braces if STRING_CST
	initializes a char/wchar_t array.
	
	* g++.dg/warn/Wbraces2.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3892.2.201&r2=1.3892.2.202
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3389.2.364&r2=1.3389.2.365
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.1174.2.31&r2=1.1174.2.32
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/warn/Wbraces2.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.6.1



-- 


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


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

* [Bug c++/20175] [3.4 Regression] Warnings are issued when initializing struct members with "strings"
  2005-02-23 20:58 [Bug c++/20175] New: Warnings are issued when initializing struct members with "strings" gcc at magfr dot user dot lysator dot liu dot se
                   ` (8 preceding siblings ...)
  2005-02-28  1:36 ` cvs-commit at gcc dot gnu dot org
@ 2005-02-28  1:42 ` jakub at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu dot org @ 2005-02-28  1:42 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From jakub at gcc dot gnu dot org  2005-02-27 18:12 -------
Fixed in CVS.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


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


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

end of thread, other threads:[~2005-02-27 18:12 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-02-23 20:58 [Bug c++/20175] New: Warnings are issued when initializing struct members with "strings" gcc at magfr dot user dot lysator dot liu dot se
2005-02-23 21:03 ` [Bug c++/20175] " gcc at magfr dot user dot lysator dot liu dot se
2005-02-23 22:21 ` [Bug c++/20175] [3.4/4.0 Regression] " pinskia at gcc dot gnu dot org
2005-02-24 15:46 ` jakub at gcc dot gnu dot org
2005-02-24 15:59 ` jakub at gcc dot gnu dot org
2005-02-25  1:49 ` cvs-commit at gcc dot gnu dot org
2005-02-25  2:04 ` [Bug c++/20175] [3.4 " pinskia at gcc dot gnu dot org
2005-02-25 19:47 ` gcc at magfr dot user dot lysator dot liu dot se
2005-02-25 19:49 ` pinskia at gcc dot gnu dot org
2005-02-28  1:36 ` cvs-commit at gcc dot gnu dot org
2005-02-28  1:42 ` jakub at gcc dot gnu dot org

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