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]

gcc 2.95.2 wrong assembly with floats and ints


The following program produces incorrect assembly code when
compiled with -O2:

#include <stdio.h>

void
gtk_vi_window_scrollbar(void *vi, unsigned int top, unsigned int size, unsigned int max)
{
    void *vi_screen;
    static float a;
    static float b;

    printf("%d %d %d\n", top, size, max);
    a = max;
    b = size;
}

int main()
{
    gtk_vi_window_scrollbar(0, 1, 2, 3);
}

skimo@pool:/home/skimo/obj/vi-cvs > gcc   test.c -o test
skimo@pool:/home/skimo/obj/vi-cvs > ./test 
1 2 3
skimo@pool:/home/skimo/obj/vi-cvs > gcc -O2  test.c -o test 
skimo@pool:/home/skimo/obj/vi-cvs > ./test                 
1 2 0

This is part of the assembly code:
00000000 <gtk_vi_window_scrollbar>:
   0:   55                      push   %ebp
   1:   89 e5                   mov    %esp,%ebp
   3:   83 ec 10                sub    $0x10,%esp
   6:   31 c9                   xor    %ecx,%ecx
   8:   56                      push   %esi
   9:   53                      push   %ebx
   a:   8b 45 0c                mov    0xc(%ebp),%eax
   d:   8b 55 10                mov    0x10(%ebp),%edx
  10:   89 4d 14                mov    %ecx,0x14(%ebp)

here the value of max is overwritten with 0

  13:   8b 5d 14                mov    0x14(%ebp),%ebx
  16:   89 55 10                mov    %edx,0x10(%ebp)
  19:   31 f6                   xor    %esi,%esi
  1b:   53                      push   %ebx
  1c:   52                      push   %edx
  1d:   50                      push   %eax
  1e:   68 00 00 00 00          push   $0x0
  23:   e8 fc ff ff ff          call   24 <gtk_vi_window_scrollbar+0x24>
 
skimo@pool:/home/skimo/obj/vi-cvs > gcc -v 
Reading specs from /usr/lib/gcc-lib/i586-pc-linux-gnu/2.95.2/specs
gcc version 2.95.2 19991024 (release)
skimo@pool:/home/skimo/obj/vi-cvs > uname -a
Linux pool 2.2.14 #8 Sun Jan 16 00:56:33 MET 2000 i586 unknown

skimo

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