nested unnamed structs/unions broken?
Steve Watt
steve@chelsio.com
Sat Oct 25 18:26:00 GMT 2003
The following code:
- - - 8< - - -
#include <stdio.h>
union optid {
unsigned int opcode_tid;
struct {
unsigned int opcode:8;
unsigned int tid:24;
};
};
struct cpl_msg {
union optid;
int item1;
};
int main() {
struct cpl_msg x;
int opcode;
int tid;
x.opcode_tid = 0x000102da;
printf("opcode %x tid %x\n", x.opcode, x.tid);
exit(0);
}
- - - >8 - - -
compiles and works with GCC 2.96 (ugh) and 3.2.2[FreeBSD] 20030205,
but with 3.4-20030819 (experimental), it fails during compilation:
tpun.c:12: warning: declaration does not declare anything
tpun.c: In function `main':
tpun.c:21: error: structure has no member named `opcode_tid'
tpun.c:23: error: structure has no member named `opcode'
tpun.c:23: error: structure has no member named `tid'
I don't have a 3.3 handy to check against. This feels like a bug
in 3.4, but I don't spot anything in the GCC Bugzilla that hints
towards it.
Thx,
--
Steve Watt KD6GGD PP-ASEL-IA Email at home: steve@watt.com
Chelsio Communications http://www.chelsio.com/ work: steve@chelsio.com
510 N. Pastoria Ave Voice: +1 408 962 3627
Sunnyvale, CA, USA, 94085 Fax: +1 408 730 2580
More information about the Gcc-bugs
mailing list