Dear fellows,

I think I discovered a bug in gcc 4.6 on Solaris i386. It appeared in 
sdcc bitfields.c host regression test in svn build 6665, when -O2 gcc 
option was included.

Here is the code in file t.c, which reproduces the bug:
----8<----
#include <stdio.h>
#pragma GCC optimize ("O2")

const struct
{
   unsigned int   : 4;
   unsigned int f : 2;
} cs = { 1 };

int main(void)
{
   printf("cs.f = %d, (sf.f == 1) = %d\n", cs.f, cs.f == 1);
}
---->8----

You can compile it:
gcc -o t t.c
and run it:
./t

The result is:
cs.f = 1, (sf.f == 1) = 0

The result of (sf.f == 1) is wrong: it should be 1.

Without the anonymous bit field structure member or if it is compiled 
without O2 optimization or if the structure is declared as volatile, it 
compiles OK.

Before submitting the bug to gcc bugzilla, I would like you to help me to:
- verify if it is really a bug (maybe I misunderstood something?)
- verify if I correctly compiled the gcc (I took the gcc 4.6 release 
tarball and compile it on Solaris i386 machine)
- verify if it is reproducible also on other Solaris i386 machines with 
the same or different gcc compiler versions

I'll appreciate any response.

Best regards,
Borut





------------------------------------------------------------------------------
Magic Quadrant for Content-Aware Data Loss Prevention
Research study explores the data loss prevention market. Includes in-depth
analysis on the changes within the DLP market, and the criteria used to
evaluate the strengths and weaknesses of these DLP solutions.
http://www.accelacomm.com/jaw/sfnl/114/51385063/
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to