--- Comment #12 from runipg at broadcom dot com 2010-09-03 21:12 ---
Subject: Re: Bug with anonymous unions and bit-fields
Okay, I guess I was confused by "struct or union" semantics. Thanks!
jakub at gcc dot gnu dot org wrote:
> --- Comment #11 from jakub at gcc dot gnu dot org
--- Comment #11 from jakub at gcc dot gnu dot org 2010-09-03 20:53 ---
I don't see anything confusing about it. If you have:
union { int a, b, c; } u;
u.a overlaps u.b and u.c as well, and the same applies to bitfields. union
isn't struct, see ISO C99 6.7.2.1/5. The standard is clear
--- Comment #10 from runipg at broadcom dot com 2010-09-03 19:19 ---
Subject: Re: Bug with anonymous unions and bit-fields
Your suggestion works:
struct bfc {
union {
struct {
unsigned int a : 1,
b : 4;
};
--- Comment #9 from runipg at broadcom dot com 2010-09-03 14:45 ---
Subject: Re: Bug with anonymous unions and bit-fields
Thank you so much. You can close this bug if you wish.
-Runip
On 03-Sep-2010, at 3:47 AM, paolo dot carlini at oracle dot com
wrote:
>
>
> --- Comment #8
--- Comment #8 from paolo dot carlini at oracle dot com 2010-09-03 10:46
---
If you look at the actual Standard, both alignment and allocation of bit-fields
are implementation defined. Thus, as far as I can see, at best we are talking
about non-portable implementation defined behavior.
--- Comment #7 from runipg at broadcom dot com 2010-09-03 03:31 ---
Subject: Re: Bug with anonymous unions and bit-fields
Wow, So there is a diff inside and outside a struct?
This is very counter-intuitive but I am to accept your explanation if that's
what the language says.
Thank
--- Comment #6 from pinskia at gcc dot gnu dot org 2010-09-03 01:13 ---
You can use a GCC extension of anonymous structs:
struct bfa {
union {
struct {
unsigned int a : 1,
b : 4;
};
unsigned int data;
};
};
To ge
--- Comment #5 from pinskia at gcc dot gnu dot org 2010-09-03 01:10 ---
union {
unsigned int a : 1,
b : 4;
unsigned int data;
};
This is an union of three elements each over lapping, that is a:1 overlaps with
b:4 and data. So this is
--- Comment #4 from paolo dot carlini at oracle dot com 2010-09-03 01:09
---
Fair enough, but first blush I also don't see any text in the C++ Standard
guaranteeing the behavior you want, wondered if you actually can get it with
other compilers, maybe as implementation defined. Somebody
--- Comment #3 from runipg at broadcom dot com 2010-09-03 01:03 ---
Subject: Re: Bug with anonymous unions and bit-fields
That was fast and interesting that two other compilers behave the same.
Unfortunately I don't have access to any other compiler. I am simply
befuddled by the beh
--- Comment #2 from paolo dot carlini at oracle dot com 2010-09-03 00:02
---
Without having seriously looked into your code, I note that two completely
different, closed source compilers (ICC and SunStudio) leads to the same
behavior as GCC at runtime. Does your code actually "work" (be
11 matches
Mail list logo