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]

optimization/9647: -O2 -fomit-frame-pointer generate wrong code


>Number:         9647
>Category:       optimization
>Synopsis:       -O2 -fomit-frame-pointer generate wrong code
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Mon Feb 10 20:06:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     bero@geocities.co.jp
>Release:        3.2.x
>Organization:
>Environment:
host=target=build=i686-pc-cygwin

Reading specs from /usr/lib/gcc-lib/i686-pc-cygwin/3.2/specs
Configured with: /netrel/src/gcc-3.2-3/configure --enable-languages=c,c++,f77,java --enable-libgcj --enable-threads=posix --with-system-zlib --enable-nls --without-included-gettext --enable-interpreter --disable-sjlj-exceptions --disable-version-specific-runtime-libs --enable-shared --build=i686-pc-linux --host=i686-pc-cygwin --target=i686-pc-cygwin --enable-haifa --prefix=/usr --exec-prefix=/usr --sysconfdir=/etc --libdir=/usr/lib --includedir=/nonexistent/include --libexecdir=/usr/sbin
Thread model: posix
gcc version 3.2 20020927 (prerelease)

Reading specs from /usr/local/lib/gcc-lib/i686-pc-cygwin/3.2.2/specs
Configured with: ../configure --enable-languages=c,c++ --with-system-zlib --enable-threads --disable-version-specific-runtime-libs --without-included-gettext --enable-shared
Thread model: win32
gcc version 3.2.2
>Description:
compile binutils-2.13.x
bfd/doc/chew.c with CFLAGS="-O2 -fomit-frame-pointer"
generate wrong code.

local valiable locate invalid memory on stack.

>How-To-Repeat:
compile binutils-2.13.x
bfd/doc/chew.c with CFLAGS="-O2 -fomit-frame-pointer"

small test code:

#include <stdio.h>

/* Here is a string type ...  */

typedef struct buffer
{
  char *ptr;
  unsigned long write_idx;
  unsigned long size;
} string_type;

static void
read_in (str, file)
     string_type *str;
     FILE *file;
{
  char buff[10000];
  unsigned int r;
  do
    {
      r = fread (buff, 1, sizeof (buff), file);
      catbuf (str, buff, r);
    }
  while (r);
  buff[0] = 0;

  catbuf (str, buff, 1);
}

Wrong code:
gcc version 3.2 20020927 (prerelease)
gcc version 3.2.2
_read_in:
	pushl	%ebp
	movl	$10028, %eax
	pushl	%edi
	pushl	%esi
	pushl	%ebx
	leal	16(%esp), %esi	<= invalid buff
	call	__alloca

Right code:
gcc 2.95.3-10 (cygwin special)
gcc 3.2.2 -O2 -fno-omit-frame-pointer
gcc 3.2.2 -O1 -fomit-frame-pointer
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


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