[Bug c/49768] New: C99 style union initializations does not work as expected with optimizations

2011-07-17 Thread vrahkone at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49768

   Summary: C99 style union initializations does not work as
expected with optimizations
   Product: gcc
   Version: 4.6.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
AssignedTo: unassig...@gcc.gnu.org
ReportedBy: vrahk...@gmail.com


Created attachment 24779
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24779
Test code that fails with 4.6.1 and works with 4.5.3

It seems that union cannot be initialized with C99 style with 4.6.1. Attached
example code works with GCC 4.5.3 but fails on assert when compiled with GCC
4.6.1. The GCC 4.6.1 seems to generate only the assert failure i.e. example
compiled with -O3:

00400500 :
  400500:   48 83 ec 08 sub$0x8,%rsp
  400504:   b9 2b 06 40 00  mov$0x40062b,%ecx
  400509:   ba 18 00 00 00  mov$0x18,%edx
  40050e:   be 0c 06 40 00  mov$0x40060c,%esi
  400513:   bf 13 06 40 00  mov$0x400613,%edi
  400518:   e8 cb fe ff ff  callq  4003e8 <__assert_fail@plt>
  40051d:   90  nop
  40051e:   90  nop
  40051f:   90  nop

It seems that using -fno-tree-pre, -fno-tree-ccp and -fno-tree-fre with -O3 the
code seems to work. Also setting the first bit in initialization seems to
generate working code i.e. rest of initialization works if it's set and also
setting the bits later seems to work too.

ps. I'm not totally sure that if this is a regression or meant to be that way
because the C-standard is not clear on this matter but following code works
with GCC 4.5.3 and the assert fails with GCC 4.6.1.


[Bug tree-optimization/49768] [4.6/4.7 Regression] C99 style union initializations does not work as expected with optimizations

2011-08-04 Thread vrahkone at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49768

--- Comment #10 from Valtteri Rahkonen  2011-08-04 
13:44:38 UTC ---
I tested latest gcc 4.6.1 from Debian unstable containing the patch and it
seems to work. I'm not going to dare to mark this as verified though because I
don't know your bugzilla policies ;).

Thanks.