public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "bepaald at yahoo dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/50531] New: ICE on defaulted template destructor
Date: Tue, 27 Sep 2011 11:54:00 -0000	[thread overview]
Message-ID: <bug-50531-4@http.gcc.gnu.org/bugzilla/> (raw)

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.


             reply	other threads:[~2011-09-27 11:38 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-27 11:54 bepaald at yahoo dot com [this message]
2011-09-27 12:32 ` [Bug c++/50531] " redi at gcc dot gnu.org
2011-10-18 19:36 ` [Bug c++/50531] [C++0x] " jason at gcc dot gnu.org
2011-10-18 19:37 ` jason at gcc dot gnu.org
2011-10-19  3:21 ` jason at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-50531-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).