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/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
>Closed-Date:
>Last-Modified:
>Originator:     
>Release:        3.1 20020506 (prerelease)
>Organization:
>Environment:
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
>Description:
life_analysis misoptimizes out code to initialize the fields of a structure.
>How-To-Repeat:
$ cat qsize.cpp
void abort (void);

struct QSize
{
  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, s1.ht+s2.ht); }

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 || s.ht != 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:
 /usr/include/g++
 /usr/include/g++/ia64-suse-linux
 /usr/include/g++/backward
 /usr/local/include
 /usr/lib/gcc-lib/ia64-suse-linux/3.1/include
 /usr/ia64-suse-linux/include
 /usr/include
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/ld-linux-ia64.so.2 /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 
Aborted
>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]