[Bug tree-optimization/48973] New: Inliner bug with one-bit (1-bit) bitfield

arthur.j.odwyer at gmail dot com gcc-bugzilla@gcc.gnu.org
Thu May 12 01:43:00 GMT 2011


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48973

           Summary: Inliner bug with one-bit (1-bit) bitfield
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: arthur.j.odwyer@gmail.com


Created attachment 24231
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24231
Output of "ajo-gcc -w -O1 -finline-small-functions test.c -v"

This reproduces for me with svn revision 173589 (2011-05-09). Since this
reproduces all the way back to 4.4, it *must* be a duplicate of *something*,
but I didn't find anything likely-looking in a Bugzilla search. I'm on Ubuntu
10.10, x86-64.

cat >test.c <<EOF
struct S0 {
   signed f0 : 1;
} g_72 = {0}; 
int f5 = -1;
void func_46(int f4) {
    g_72.f0 = (f5 & 1) > 0;
}
int main() {
    func_46(-1);
    printf("%x\n", (unsigned int)(g_72.f0));
    return 0;
}
EOF
gcc -w -O1 test.c -o a.out ; ./a.out
gcc -w -O2 test.c -o a.out ; ./a.out

REDUCED: gcc -w -O1 -finline-small-functions test.c -o a.out ; ./a.out

With -O1 the output is "ffffffff". With -O2 the output is "1". g_72.f0 should
evaluate to -1, and then casting that to (unsigned int) should always yield
0xffffffff regardless of optimization level. This looks to me like an inliner
bug.

In gcc 4.4.5 and 4.5.1, the bug also reproduces when you use "f4" instead of
"f5" inside func_46(). In trunk, you need to use a global variable to see the
bug.

This test case is reduced from the output of Csmith 2.1.0 (git hash 541a6480,
https://github.com/csmith-project/csmith/), using the following command line:
csmith --no-paranoid --no-longlong --no-pointers --arrays --no-jumps --consts
--no-volatiles --checksum --no-divs --no-muls --bitfields --packed-struct -s
1281232940



More information about the Gcc-bugs mailing list