This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/19079] New: Unamed struct/union issues with typedef
- From: "frantas at brfree dot com dot br" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 19 Dec 2004 12:58:19 -0000
- Subject: [Bug c/19079] New: Unamed struct/union issues with typedef
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
The following code generates an error with gcc-3.4.3. It compiles fine with
gcc-3.2.3. Please see the comments in the code.
--------------- code -----------------
typedef union { int b; float c; } MyUnionType;
MyUnionType bar;
struct {
int a;
union {
int b;
float c;
};
int d;
} foo;
struct {
int a;
MyUnionType x;
int d;
} foo1;
struct {
int a;
MyUnionType; /* here we get a warning */
int d;
} foo2;
void test(void) {
bar.b = 1; /* the typedef works */
foo.b = 2; /* the unamed union in the struct works */
foo1.x.b = 3; /* the typedefed union in the struct works */
foo2.b = 4; /* but not if unamed - here we get an error */
}
---------------- end of code --------------------
---------------- compiler output ----------------
Reading specs from /opt/gcc/lib/gcc/i686-pc-linux-gnu/3.4.3/specs
Configured with: ../configure --prefix=/opt/gcc
Thread model: posix
gcc version 3.4.3
/opt/gcc/libexec/gcc/i686-pc-linux-gnu/3.4.3/cc1 -E -quiet -v unamedstruct.c
-mtune=pentiumpro -o unamedstruct.i
ignoring nonexistent directory
"/opt/gcc/lib/gcc/i686-pc-linux-gnu/3.4.3/../../../../i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/opt/gcc/include
/opt/gcc/lib/gcc/i686-pc-linux-gnu/3.4.3/include
/usr/include
End of search list.
/opt/gcc/libexec/gcc/i686-pc-linux-gnu/3.4.3/cc1 -fpreprocessed unamedstruct.i
-quiet -dumpbase unamedstruct.c -mtune=pentiumpro -auxbase unamedstruct -version
-o unamedstruct.s
GNU C version 3.4.3 (i686-pc-linux-gnu)
compiled by GNU C version 3.3.3 (release).
GGC heuristics: --param ggc-min-expand=62 --param ggc-min-heapsize=60386
unamedstruct.c:22: warning: declaration does not declare anything
unamedstruct.c: In function `test':
unamedstruct.c:30: error: structure has no member named `b'
-------------end of compiler output -------------
--
Summary: Unamed struct/union issues with typedef
Product: gcc
Version: 3.4.3
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: frantas at brfree dot com dot br
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=19079