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]

c++/2210: ice, abi bug, virtual functions, optimization off



>Number:         2210
>Category:       c++
>Synopsis:       ice, abi bug, virtual functions, optimization off
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          ice-on-legal-code
>Submitter-Id:   net
>Arrival-Date:   Wed Mar 07 11:16:01 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     Peter Schmid
>Release:        3.1 20010307 (experimental)
>Organization:
TU Darmstadt
>Environment:
System: Linux kiste 2.4.2 #34 Sun Feb 25 20:03:34 CET 2001 i686 unknown
Architecture: i686
SuSE 7.1 
Glibc 2.2
GNU ld version 2.10.91 (with BFD 2.10.91.0.4)
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ../gcc/configure --enable-shared --disable-nls --enable-threads=posix --enable-long-long
>Description:
The following legal source code tb.C causes an internal compiler error
in instantiate_template. This does not happen if at least one of the
virtual keywords is removed, the enum is replaced with a built-in type,
the function test1() is moved directly in front of the function
tests() or optimization is turned on. The code did not crash the
compiler when -fno-new-abi was active for previous compiler
snapshots. Maybe this is an abi bug? 

Gcc-2.95.2 compiles the code without a problem. 
Note: The functions void f(A<T> d) and void g(A<T> &d) are never
called, but are needed to provoke the compiler crash. Gcc-3.0 did also
crash when I tryed about two weeks ago.


>How-To-Repeat:
source file tb.C

void tests();

template<class T>
class A {
public:
  virtual ~A(){}; 
};

class B {
public:
  enum r {};
  virtual void e(r a){};
};

template<class T>
class C
  : public B, 
    private A<T> 
{
public:
  C(){};
};


int main()
{
  tests();
}
template<class T>
void f(C<T> d){}

template<class T>
void g(C<T> &d)
{
  f(d);
}

void test1()
{
  C<int> d;
  g(d);
}

template<class T>
void f(A<T> d){}

template<class T>
void g(A<T> &d)
{
  f(d);
}

void tests()
{
    test1();
}

Compiling tb.C without optimization fails

g++ -v -o tb tb.C -W -Wall -save-temps
Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/specs
Configured with: ../gcc/configure --enable-shared --disable-nls --enable-threads=posix --enable-long-long
gcc version 3.1 20010307 (experimental)
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/cpp0 -lang-c++ -D_GNU_SOURCE -D__GNUG__=3 -D__EXCEPTIONS -D__GXX_ABI_VERSION=100 -v -D__GNUC__=3 -D__GNUC_MINOR__=1 -D__GNUC_PATCHLEVEL__=0 -D__ELF__ -Dunix -Dlinux -D__ELF__ -D__unix__ -D__linux__ -D__unix -D__linux -Asystem=posix -D__STDC_HOSTED__=1 -W -Wall -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i686__ -D__tune_pentiumpro__ tb.C tb.ii
GNU CPP version 3.1 20010307 (experimental) (cpplib) (i386 Linux/ELF)
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include/g++-v3
 /usr/local/include/g++-v3/i686-pc-linux-gnu
 /usr/local/include
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/include
 /usr/local/i686-pc-linux-gnu/include
 /usr/include
End of search list.
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/cc1plus -fpreprocessed tb.ii -quiet -dumpbase tb.C -W -Wall -version -o tb.s
GNU CPP version 3.1 20010307 (experimental) (cpplib) (i386 Linux/ELF)
GNU C++ version 3.1 20010307 (experimental) (i686-pc-linux-gnu)
	compiled by GNU C version 3.1 20010307 (experimental).
tb.C: In function `void g(C<T>&) [with T = int]':
tb.C:41:   instantiated from here
tb.C:35: Internal error #283.
tb.C:35: Internal compiler error in instantiate_template, at cp/pt.c:7605
Please submit a full bug report, with preprocessed source if appropriate.
See <URL:http://www.gnu.org/software/gcc/bugs.html> for instructions.

Compiling tb.C with optimization "-O" or whatever works 
g++ -O -v -o tb tb.C -W -Wall -save-temps
Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/specs
Configured with: ../gcc/configure --enable-shared --disable-nls --enable-threads=posix --enable-long-long
gcc version 3.1 20010307 (experimental)
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/cpp0 -lang-c++ -D_GNU_SOURCE -D__GNUG__=3 -D__EXCEPTIONS -D__GXX_ABI_VERSION=100 -v -D__GNUC__=3 -D__GNUC_MINOR__=1 -D__GNUC_PATCHLEVEL__=0 -D__ELF__ -Dunix -Dlinux -D__ELF__ -D__unix__ -D__linux__ -D__unix -D__linux -Asystem=posix -D__OPTIMIZE__ -D__STDC_HOSTED__=1 -W -Wall -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i686__ -D__tune_pentiumpro__ tb.C tb.ii
GNU CPP version 3.1 20010307 (experimental) (cpplib) (i386 Linux/ELF)
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include/g++-v3
 /usr/local/include/g++-v3/i686-pc-linux-gnu
 /usr/local/include
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/include
 /usr/local/i686-pc-linux-gnu/include
 /usr/include
End of search list.
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/cc1plus -fpreprocessed tb.ii -quiet -dumpbase tb.C -O -W -Wall -version -o tb.s
GNU CPP version 3.1 20010307 (experimental) (cpplib) (i386 Linux/ELF)
GNU C++ version 3.1 20010307 (experimental) (i686-pc-linux-gnu)
	compiled by GNU C version 3.1 20010307 (experimental).
tb.C: In method `virtual void B::e(B::r)':
tb.C:12: warning: unused parameter `B::r a'
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/../../../../i686-pc-linux-gnu/bin/as -V -Qy -o tb.o tb.s
GNU assembler version 2.10.91 (i686-pc-linux-gnu) using BFD version 2.10.91.0.4
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/collect2 -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 -o tb /usr/lib/crt1.o /usr/lib/crti.o /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/crtbegin.o -L/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1 -L/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/../../../../i686-pc-linux-gnu/lib -L/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/../../.. tb.o -lstdc++ -lm -lgcc_s -lc -lgcc_s /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/crtend.o /usr/lib/crtn.o

Preprocessed source file tb.ii

# 1 "tb.C"
void tests();

template<class T>
class A {
public:
  virtual ~A(){};
};

class B {
public:
  enum r {};
  virtual void e(r a){};
};

template<class T>
class C
  : public B,
    private A<T>
{
public:
  C(){};
};


int main()
{
  tests();
}
template<class T>
void f(C<T> d){}

template<class T>
void g(C<T> &d)
{
  f(d);
}

void test1()
{
  C<int> d;
  g(d);
}

template<class T>
void f(A<T> d){}

template<class T>
void g(A<T> &d)
{
  f(d);
}

void tests()
{
    test1();
}


>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]