[Bug c++/50531] New: ICE on defaulted template destructor
bepaald at yahoo dot com
gcc-bugzilla@gcc.gnu.org
Tue Sep 27 11:54:00 GMT 2011
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50531
Bug #: 50531
Summary: ICE on defaulted template destructor
Classification: Unclassified
Product: gcc
Version: 4.6.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: bepaald@yahoo.com
Created attachment 25370
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=25370
Preprocessed source that triggers ICE
In a program I'm writing I encoutered dozens of ICEs due to bug 49507. After
upgrading to 4.6.1, all but one disappeared. The following code shows an
example.
//-- datafilter.h --
#ifndef DATAFILTER_H_
#define DATAFILTER_H_
template <typename T>
class DataFilter
{
public:
inline virtual ~DataFilter();
virtual void dataUpdate(int, int) = 0;
virtual void dataStart(int, int);
};
template<typename T>
inline DataFilter<T>::~DataFilter() = default;
#endif
//-- arcalculator.h --
#ifndef ARCALCULATOR_H_
#define ARCALCULATOR_H_
#include "datafilter.h"
class ARCalculator : public DataFilter<ARCalculator>
{
public:
ARCalculator() = default;
// the function declared first will generate an ICE
virtual void dataStart(int, int);
virtual void dataUpdate(int, int);
};
#endif
//-- datastart.cc --
#include "arcalculator.h"
void ARCalculator::dataStart(int, int)
{}
//-- dataupdate.cc --
#include "arcalculator.h"
void ARCalculator::dataUpdate(int, int)
{}
Strangely, even though the two functions (dataStart and dataUpdate) are
identical, one will compile fine while the other generates an ICE:
$ g++ -c -std=c++0x -Wall -Wextra -save-temps dataupdate.cc # compiles fine
$ g++ -c -std=c++0x -Wall -Wextra -save-temps datastart.cc # generates ICE
In file included from arcalculator.h:4:0,
from datastart.cc:1:
datafilter.h: In destructor 'DataFilter<T>::~DataFilter() [with T =
ARCalculator]':
arcalculator.h:5:7: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://bugzilla.redhat.com/bugzilla> for instructions.
Preprocessed source stored into /tmp/cccoDyUu.out file, please attach this to
your bugreport.
$
By switching the declarations of dataStart() and dataUpdate() in
arcalculator.h, the source which gives the error is also switched: whichever
function is declared first in the header, will generate the ICE when compiled.
g++ version info:
$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/i686-redhat-linux/4.6.1/lto-wrapper
Target: i686-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla
--enable-bootstrap --enable-shared --enable-threads=posix
--enable-checking=release --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-gnu-unique-object
--enable-linker-build-id
--enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin
--enable-java-awt=gtk --disable-dssi
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre
--enable-libgcj-multifile --enable-java-maintainer-mode
--with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib
--with-ppl --with-cloog --with-tune=generic --with-arch=i686
--build=i686-redhat-linux
Thread model: posix
gcc version 4.6.1 20110908 (Red Hat 4.6.1-9) (GCC)
Preprocessed source is attached.
More information about the Gcc-bugs
mailing list