This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/49768] C99 style union initializations does not work as expected with optimizations
- From: "mikpe at it dot uu.se" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 17 Jul 2011 12:47:34 +0000
- Subject: [Bug c/49768] C99 style union initializations does not work as expected with optimizations
- Auto-submitted: auto-generated
- References: <bug-49768-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49768
--- Comment #1 from Mikael Pettersson <mikpe at it dot uu.se> 2011-07-17 12:47:17 UTC ---
Created attachment 24780
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24780
reduced test case
This reduced test case doesn't use any union, just a struct with two one-bit
fields, and fails at -O1 and above with 4.6 and 4.7 on i686-linux. Looking at
the generated code, gcc has removed all runtime checks and just inserted a call
to abort.
/* pr49768.c */
int main(void)
{
static struct {
unsigned int :1;
unsigned int test_bit2:1;
} test = {
.test_bit2 = 1,
};
if (test.test_bit2 != 1)
__builtin_abort();
return 0;
}