public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* RE: nested unnamed structs/unions broken?
@ 2003-10-26 19:04 Steve Watt
2003-10-28 1:56 ` Jim Wilson
0 siblings, 1 reply; 4+ messages in thread
From: Steve Watt @ 2003-10-26 19:04 UTC (permalink / raw)
To: Jim Wilson; +Cc: gcc-bugs
Then that needs a doc fix, as it isn't mentioned anywhere. The headers in question aren't from MS, they were developed in-house. Guess we need to change them for 3.4.
Thanks for the info.
-----Original Message-----
From: Jim Wilson [mailto:wilson@specifixinc.com]
Sent: Sun 10/26/2003 11:44 AM
To: Steve Watt
Cc: gcc-bugs@gcc.gnu.org
Subject: Re: nested unnamed structs/unions broken?
Steve Watt wrote:
> union optid {
> unsigned int opcode_tid;
> struct {
> unsigned int opcode:8;
> unsigned int tid:24;
> };
> };
You now need the -fms-extensions option in order for gcc to accept this.
This feature was originally added because it was used in MS Windows
header files, and was thus needed by cygwin. Some people objected to
the feature when it accidentally turned up in other places, so now it
only gets enabled if you explicitly ask for MSC compatibility.
There is one case that gcc continues to accept by default, because it
was agreed to be generally useful. This is the case of a union inside a
struct, where the union has no type name and no field name. This is the
case documented in the gcc manual in the Unnamed Fields node.
http://gcc.gnu.org/onlinedocs/gcc-3.3.1/gcc/Unnamed-Fields.html#Unnamed%20Fields
--
Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: nested unnamed structs/unions broken?
2003-10-26 19:04 nested unnamed structs/unions broken? Steve Watt
@ 2003-10-28 1:56 ` Jim Wilson
0 siblings, 0 replies; 4+ messages in thread
From: Jim Wilson @ 2003-10-28 1:56 UTC (permalink / raw)
To: Steve Watt; +Cc: gcc-bugs
On Sun, 2003-10-26 at 10:48, Steve Watt wrote:
> Then that needs a doc fix, as it isn't mentioned anywhere.
I agree. Since your earlier bug report was already closed as invalid, I
took the liberty of creating another one. This is now 12802 in
bugzilla.
--
Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: nested unnamed structs/unions broken?
2003-10-25 18:26 Steve Watt
@ 2003-10-26 18:49 ` Jim Wilson
0 siblings, 0 replies; 4+ messages in thread
From: Jim Wilson @ 2003-10-26 18:49 UTC (permalink / raw)
To: Steve Watt; +Cc: gcc-bugs
Steve Watt wrote:
> union optid {
> unsigned int opcode_tid;
> struct {
> unsigned int opcode:8;
> unsigned int tid:24;
> };
> };
You now need the -fms-extensions option in order for gcc to accept this.
This feature was originally added because it was used in MS Windows
header files, and was thus needed by cygwin. Some people objected to
the feature when it accidentally turned up in other places, so now it
only gets enabled if you explicitly ask for MSC compatibility.
There is one case that gcc continues to accept by default, because it
was agreed to be generally useful. This is the case of a union inside a
struct, where the union has no type name and no field name. This is the
case documented in the gcc manual in the Unnamed Fields node.
http://gcc.gnu.org/onlinedocs/gcc-3.3.1/gcc/Unnamed-Fields.html#Unnamed%20Fields
--
Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com
^ permalink raw reply [flat|nested] 4+ messages in thread
* nested unnamed structs/unions broken?
@ 2003-10-25 18:26 Steve Watt
2003-10-26 18:49 ` Jim Wilson
0 siblings, 1 reply; 4+ messages in thread
From: Steve Watt @ 2003-10-25 18:26 UTC (permalink / raw)
To: bug-gcc
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
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2003-10-28 1:45 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-10-26 19:04 nested unnamed structs/unions broken? Steve Watt
2003-10-28 1:56 ` Jim Wilson
-- strict thread matches above, loose matches on Subject: below --
2003-10-25 18:26 Steve Watt
2003-10-26 18:49 ` Jim Wilson
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).