This is the mail archive of the 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/6631: Miscompiled structure access

>Number:         6631
>Category:       optimization
>Synopsis:       Miscompiled structure access
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Fri May 10 18:26:01 PDT 2002
>Release:        3.1 20020506 (prerelease)
System: Linux sykes 2.4.18-SMP #1 SMP Sat Apr 13 18:56:25 UTC 2002 ia64 unknown unknown GNU/Linux
Architecture: ia64

host: ia64-suse-linux-gnu
build: ia64-suse-linux-gnu
target: ia64-suse-linux-gnu
configured with: ../configure --enable-threads=posix --prefix=/usr --with-local-prefix=/usr/local --infodir=/usr/share/info --mandir=/usr/share/man --libdir=/usr/lib --enable-languages=c,c++,f77,objc,java,ada --with-gxx-include-dir=/usr/include/g++ --with-slibdir=/lib --with-system-zlib --enable-shared --enable-checking ia64-suse-linux
life_analysis misoptimizes out code to initialize the fields of a structure.
$ cat qsize.cpp
void abort (void);

struct QSize
  QSize( int w, int h );
  int wd, ht;
  friend inline const QSize operator+( const QSize &, const QSize & );

inline QSize::QSize()
{ wd = ht = -1; }

inline QSize::QSize( int w, int h )
{ wd = w; ht = h; }

inline const QSize operator+( const QSize & s1, const QSize & s2 )
{ return QSize(s1.wd+s2.wd,; }

QSize minimumSize()
  return QSize (100, 200);

QSize totalMinimumSize()
    QSize s = minimumSize();
    return s + QSize( 0, 0 );

int main()
  QSize s = totalMinimumSize();
  if (s.wd != 100 || != 200)
    abort ();
$ gcc -O -v qsize.cpp 
Reading specs from /usr/lib/gcc-lib/ia64-suse-linux/3.1/specs
Configured with: ../configure --enable-threads=posix --prefix=/usr --with-local-prefix=/usr/local --infodir=/usr/share/info --mandir=/usr/share/man --libdir=/usr/lib --enable-languages=c,c++,f77,objc,java,ada --with-gxx-include-dir=/usr/include/g++ --with-slibdir=/lib --with-system-zlib --enable-shared --enable-checking ia64-suse-linux
Thread model: posix
gcc version 3.1 20020506 (prerelease)
 /usr/lib/gcc-lib/ia64-suse-linux/3.1/cc1plus -v -D__GNUC__=3 -D__GNUC_MINOR__=1 -D__GNUC_PATCHLEVEL__=0 -D__gnu_linux__ -D__linux -D__linux__ -D_LONGLONG -Dlinux -Dunix -D__gnu_linux__ -D__linux -D__linux__ -D_LONGLONG -D__linux__ -D__unix__ -D__linux -D__unix -Asystem=linux -D__OPTIMIZE__ -D__STDC_HOSTED__=1 -D_GNU_SOURCE -Acpu=ia64 -Amachine=ia64 -D__ia64 -D__ia64__ -D_LP64 -D__LP64__ -D__ELF__ -D__LONG_MAX__=9223372036854775807L qsize.cpp -D__GNUG__=3 -D__DEPRECATED -D__EXCEPTIONS -D__GXX_ABI_VERSION=100 -quiet -dumpbase qsize.cpp -O -version -o /tmp/ccd2tZb1.s
GNU CPP version 3.1 20020506 (prerelease) (cpplib) (IA-64) Linux
GNU C++ version 3.1 20020506 (prerelease) (ia64-suse-linux)
        compiled by GNU C version 3.1 20020506 (prerelease).
#include "..." search starts here:
#include <...> search starts here:
End of search list.
 /usr/lib/gcc-lib/ia64-suse-linux/3.1/../../../../ia64-suse-linux/bin/as -x -o /tmp/cci5U9Z1.o /tmp/ccd2tZb1.s
 /usr/lib/gcc-lib/ia64-suse-linux/3.1/collect2 -dynamic-linker /lib/ /usr/lib/gcc-lib/ia64-suse-linux/3.1/../../../crt1.o /usr/lib/gcc-lib/ia64-suse-linux/3.1/../../../crti.o /usr/lib/gcc-lib/ia64-suse-linux/3.1/crtbegin.o -L/usr/lib/gcc-lib/ia64-suse-linux/3.1 -L/usr/lib/gcc-lib/ia64-suse-linux/3.1/../../../../ia64-suse-linux/lib -L/usr/lib/gcc-lib/ia64-suse-linux/3.1/../../.. /tmp/cci5U9Z1.o -lgcc -lgcc_eh -lc -lgcc -lgcc_eh /usr/lib/gcc-lib/ia64-suse-linux/3.1/crtend.o /usr/lib/gcc-lib/ia64-suse-linux/3.1/../../../crtn.o
You have new mail in /suse/schwab/Mail/.incoming
$ ./a.out 

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