public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/17188] New: struct Foo { }
@ 2004-08-25 18:27 terra at gnome dot org
  2004-08-25 18:41 ` [Bug c/17188] " pinskia at gcc dot gnu dot org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: terra at gnome dot org @ 2004-08-25 18:27 UTC (permalink / raw)
  To: gcc-bugs

When an empty structure or union is defined twice, no error is given.

struct Foo { };
struct Foo { };

> gcc-3.4 -std=c99 -pedantic -Wall ~/foo.c
/home/welinder/foo.c:1: warning: struct has no members
/home/welinder/foo.c:2: warning: struct has no members

If I add members, say "int : 1;", I get 

struct Foo { int : 1; };
struct Foo { int : 1; };

> gcc-3.4 -std=c99 -pedantic -Wall ~/foo.c
/home/welinder/foo.c:1: warning: struct has no named members
/home/welinder/foo.c:2: error: redefinition of `struct Foo'
/home/welinder/foo.c:2: warning: struct has no named members


And the mid-point would be...

struct Foo { };
struct Foo { int : 1; };
> gcc-3.4 -std=c99 -pedantic -Wall ~/foo.c
/home/welinder/foo.c:1: warning: struct has no members
/home/welinder/foo.c:2: warning: struct has no named members


Note, that empty structures is a gcc extension.

-- 
           Summary: struct Foo { }
           Product: gcc
           Version: 3.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: terra at gnome dot org
                CC: gcc-bugs at gcc dot gnu dot org


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


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

* [Bug c/17188] struct Foo { }
  2004-08-25 18:27 [Bug c/17188] New: struct Foo { } terra at gnome dot org
@ 2004-08-25 18:41 ` pinskia at gcc dot gnu dot org
  2004-08-25 22:41 ` bangerth at dealii dot org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-08-25 18:41 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-08-25 18:41 -------
I don't know about the GCC extension that well but it looks to me that an empty struct is acting as the 
same as forward declaring the struct.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |minor


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


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

* [Bug c/17188] struct Foo { }
  2004-08-25 18:27 [Bug c/17188] New: struct Foo { } terra at gnome dot org
  2004-08-25 18:41 ` [Bug c/17188] " pinskia at gcc dot gnu dot org
@ 2004-08-25 22:41 ` bangerth at dealii dot org
  2004-08-25 23:32 ` pinskia at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: bangerth at dealii dot org @ 2004-08-25 22:41 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at dealii dot org  2004-08-25 22:41 -------
That would be completely bogus. I hope gcc doesn't do this. It's clearly 
a bug. 
 
W. 
 

-- 


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


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

* [Bug c/17188] struct Foo { }
  2004-08-25 18:27 [Bug c/17188] New: struct Foo { } terra at gnome dot org
  2004-08-25 18:41 ` [Bug c/17188] " pinskia at gcc dot gnu dot org
  2004-08-25 22:41 ` bangerth at dealii dot org
@ 2004-08-25 23:32 ` pinskia at gcc dot gnu dot org
  2004-09-17  2:28 ` [Bug c/17188] struct Foo { } redefinition giovannibajo at libero dot it
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-08-25 23:32 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-08-25 23:32 -------
Not  if it was not on purpose as an extension of C which is tottally likely because C does not have 
empty structs.

-- 


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


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

* [Bug c/17188] struct Foo { } redefinition
  2004-08-25 18:27 [Bug c/17188] New: struct Foo { } terra at gnome dot org
                   ` (2 preceding siblings ...)
  2004-08-25 23:32 ` pinskia at gcc dot gnu dot org
@ 2004-09-17  2:28 ` giovannibajo at libero dot it
  2004-09-17  3:14 ` pinskia at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: giovannibajo at libero dot it @ 2004-09-17  2:28 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From giovannibajo at libero dot it  2004-09-17 02:28 -------
Confirmed, not a regression (assuming the bug report is valid in the first 
place - I don't know C standard that well):

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
           Keywords|                            |accepts-invalid
      Known to fail|                            |2.95.3 3.0.4 3.2.3 3.3.3
                   |                            |3.4.0 4.0.0
   Last reconfirmed|0000-00-00 00:00:00         |2004-09-17 02:28:42
               date|                            |
            Summary|struct Foo { }              |struct Foo { } redefinition


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


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

* [Bug c/17188] struct Foo { } redefinition
  2004-08-25 18:27 [Bug c/17188] New: struct Foo { } terra at gnome dot org
                   ` (3 preceding siblings ...)
  2004-09-17  2:28 ` [Bug c/17188] struct Foo { } redefinition giovannibajo at libero dot it
@ 2004-09-17  3:14 ` pinskia at gcc dot gnu dot org
  2004-09-24 17:22 ` cvs-commit at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-09-17  3:14 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-09-17 03:14 -------
Since empty structs are extensions, this would then need to be invalid GNU C which it might mean 
anything then (and it might in fact be right to accept it).

-- 


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


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

* [Bug c/17188] struct Foo { } redefinition
  2004-08-25 18:27 [Bug c/17188] New: struct Foo { } terra at gnome dot org
                   ` (4 preceding siblings ...)
  2004-09-17  3:14 ` pinskia at gcc dot gnu dot org
@ 2004-09-24 17:22 ` cvs-commit at gcc dot gnu dot org
  2004-09-24 17:34 ` pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-09-24 17:22 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2004-09-24 17:22 -------
Subject: Bug 17188

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	jsm28@gcc.gnu.org	2004-09-24 17:22:20

Modified files:
	gcc            : ChangeLog c-decl.c 
	gcc/testsuite  : ChangeLog 
	gcc/testsuite/gcc.dg: decl-3.c 
Added files:
	gcc/testsuite/gcc.dg: nested-redef-1.c pr17188-1.c 

Log message:
	PR c/17188
	* c-decl.c (diagnose_mismatched_decls): Check for duplicate
	declarations of enumerators.
	(start_struct): Check TYPE_SIZE rather than TYPE_FIELDS to check
	for redefinition.  Check for nested redefinition.
	(finish_struct): Don't check for nested redefinition.
	(start_enum): Check for nested redefinition.
	
	testsuite:
	* gcc.dg/nested-redef-1.c, gcc.dg/pr17188-1.c: New tests.
	* gcc.dg/decl-3.c: Adjust expected message.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.5603&r2=2.5604
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-decl.c.diff?cvsroot=gcc&r1=1.588&r2=1.589
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.4344&r2=1.4345
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/nested-redef-1.c.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/pr17188-1.c.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/decl-3.c.diff?cvsroot=gcc&r1=1.2&r2=1.3



-- 


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


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

* [Bug c/17188] struct Foo { } redefinition
  2004-08-25 18:27 [Bug c/17188] New: struct Foo { } terra at gnome dot org
                   ` (5 preceding siblings ...)
  2004-09-24 17:22 ` cvs-commit at gcc dot gnu dot org
@ 2004-09-24 17:34 ` pinskia at gcc dot gnu dot org
  2005-07-28 23:03 ` cvs-commit at gcc dot gnu dot org
  2005-07-28 23:12 ` jsm28 at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-09-24 17:34 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-09-24 17:34 -------
Fixed.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.0.0


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


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

* [Bug c/17188] struct Foo { } redefinition
  2004-08-25 18:27 [Bug c/17188] New: struct Foo { } terra at gnome dot org
                   ` (6 preceding siblings ...)
  2004-09-24 17:34 ` pinskia at gcc dot gnu dot org
@ 2005-07-28 23:03 ` cvs-commit at gcc dot gnu dot org
  2005-07-28 23:12 ` jsm28 at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-07-28 23:03 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2005-07-28 23:02 -------
Subject: Bug 17188

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_4-branch
Changes by:	jsm28@gcc.gnu.org	2005-07-28 23:01:31

Modified files:
	gcc            : ChangeLog c-decl.c 
	gcc/testsuite  : ChangeLog 
	gcc/testsuite/gcc.dg: decl-3.c 
Added files:
	gcc/testsuite/gcc.dg: nested-redef-1.c pr17188-1.c 

Log message:
	PR c/17188
	PR c/21899
	* c-decl.c (diagnose_mismatched_decls): Check for duplicate
	declarations of enumerators.
	(start_struct): Check TYPE_SIZE rather than TYPE_FIELDS to check
	for redefinition.  Check for nested redefinition.
	(finish_struct): Don't check for nested redefinition.
	(start_enum): Check for nested redefinition.
	
	testsuite:
	* gcc.dg/nested-redef-1.c, gcc.dg/pr17188-1.c: New tests.
	* gcc.dg/decl-3.c: Adjust expected message.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=2.2326.2.889&r2=2.2326.2.890
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-decl.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.470.4.20&r2=1.470.4.21
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.414&r2=1.3389.2.415
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/nested-redef-1.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.60.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/pr17188-1.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.60.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/decl-3.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.2&r2=1.2.4.1



-- 


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


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

* [Bug c/17188] struct Foo { } redefinition
  2004-08-25 18:27 [Bug c/17188] New: struct Foo { } terra at gnome dot org
                   ` (7 preceding siblings ...)
  2005-07-28 23:03 ` cvs-commit at gcc dot gnu dot org
@ 2005-07-28 23:12 ` jsm28 at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2005-07-28 23:12 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From jsm28 at gcc dot gnu dot org  2005-07-28 23:10 -------
Patch backported to 3.4 branch since bug 21899 showed some cases were regressions.


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.0.0                       |3.4.5


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


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

end of thread, other threads:[~2005-07-28 23:10 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-25 18:27 [Bug c/17188] New: struct Foo { } terra at gnome dot org
2004-08-25 18:41 ` [Bug c/17188] " pinskia at gcc dot gnu dot org
2004-08-25 22:41 ` bangerth at dealii dot org
2004-08-25 23:32 ` pinskia at gcc dot gnu dot org
2004-09-17  2:28 ` [Bug c/17188] struct Foo { } redefinition giovannibajo at libero dot it
2004-09-17  3:14 ` pinskia at gcc dot gnu dot org
2004-09-24 17:22 ` cvs-commit at gcc dot gnu dot org
2004-09-24 17:34 ` pinskia at gcc dot gnu dot org
2005-07-28 23:03 ` cvs-commit at gcc dot gnu dot org
2005-07-28 23:12 ` jsm28 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).