This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

bug found in gcc 3.2


Attached please find a bug report file, including version information,
command lines showing the bug in action (viz., different results for -O1 and -O2),
a listing of the (very short) program, and the assembler listing for -O2.
This bug showed up in the orc-2.0 f90 front end.

The .s file clearly shows the error: use of the high-order part of the long long before
it is assigned to.  In the simple code here the only use is pushing on the stack for printf,
but in orc-2.0 it had other effects downstream.

Basically, the instruction
        movl    $2097152, -4(%ebp)
should have occurred before the
        pushl   -4(%ebp)


-- Alan Wray
-- NASA/Ames
-- 650-604-6066

$ gcc -v
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --host=i386-redhat-linux --with-system-zlib --enable-__cxa_atexit
Thread model: posix
gcc version 3.2 20020903 (Red Hat Linux 8.0 3.2-7)

$ gcc -O1 testLL.c

$ ./a.out
doing 1:        0,  200000    20000000000000

$ gcc -O2 testLL.c

$ ./a.out
doing 1:        0,bffff844    20000000000000

$ cat testLL.c
#include <stdio.h>
int main() {
  long long max_size;
  long mc[2];
                     max_size = 0400000000000000000LL;
                     mc[0] = *((long *)&max_size);
                     mc[1] = *(((long *)&max_size)+1);
            printf("doing 1: %8lx,%8lx  %16llx\n",mc[0],mc[1],max_size);
}

$ gcc -S -O2 testLL.c

$ cat testLL.s
        .file   "testLL.c"
        .section        .rodata.str1.1,"aMS",@progbits,1
.LC0:
        .string "doing 1: %8lx,%8lx  %16llx\n"
        .text
        .align 2
        .p2align 2,,3
.globl main
        .type   main,@function
main:
        pushl   %ebp
        movl    %esp, %ebp
        subl    $8, %esp
        andl    $-16, %esp
        subl    $12, %esp
        pushl   $2097152
        pushl   $0
        pushl   -4(%ebp)
        movl    $0, -8(%ebp)
        pushl   -8(%ebp)
        pushl   $.LC0
        movl    $2097152, -4(%ebp)
        call    printf
        leave
        ret
.Lfe1:
        .size   main,.Lfe1-main
        .ident  "GCC: (GNU) 3.2 20020903 (Red Hat Linux 8.0 3.2-7)"


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]