public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/40808]  New: member template specialization causes ICE
@ 2009-07-20  6:13 mark at austrics dot com dot au
  2009-08-25 14:17 ` [Bug c++/40808] [4.4/4.5 regression] " bangerth at gmail dot com
                   ` (7 more replies)
  0 siblings, 8 replies; 10+ messages in thread
From: mark at austrics dot com dot au @ 2009-07-20  6:13 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 3416 bytes --]

Hi,

The following short code example produces an internal
compiler error with g++ 4.4.0.

struct Void {};

template <class R> struct FunType {
  typedef R ResultType;
};

struct WrongNumberOfSigArgs {};

template <typename R> struct CFunType {
  template <class Dummy1=Void, class Dummy2=Void> struct Sig : public
FunType<WrongNumberOfSigArgs> {};
  template <class Dummy> struct Sig<Void,Dummy> : public FunType<R> {};
};

struct Dummy {
  template <typename F> typename F::template Sig<>::ResultType operator()(F
const& f) const {
    return typename F::template Sig<>::ResultType(0);
  }
};

struct Gen: public CFunType<int> {
  int operator()() const {return 0;}
  Gen() {}
};

int myfunction() {
  return Dummy()(Gen());
}

int main() {
  myfunction();
}

I believe the above code is invalid.  But g++ should
stop with an error report rather than an internal
compiler error.  To make the code valid, in Dummy,
replace the two instances of Sig<> with Sig<Void>.

(With g++ 4.3.3 the code compiles fine -- which it 
shouldn't -- and seems to choose the wrong member 
template.)

The commandline I ran, and associated output is as follows.

$ LD_LIBRARY_PATH=/usr6/ausdev/32/gcc/lib: /usr6/ausdev/32/gcc/bin/g++ -v
templatebug.cc 
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ./configure --prefix=/usr6/ausdev/32/gcc
--enable-threads=posix --enable-__cxa_atexit --enable-languages=c,c++
--with-gmp=/usr6/ausdev/tools/build/gmp
--with-mpfr=/usr6/ausdev/tools/build/mpfr --with-gnu-as
--with-as=/usr6/ausdev/32/gcc/bin/as
Thread model: posix
gcc version 4.4.0 (GCC) 
COLLECT_GCC_OPTIONS='-v' '-shared-libgcc' '-mtune=generic'
 /usr6/ausdev/32/gcc/libexec/gcc/i686-pc-linux-gnu/4.4.0/cc1plus -quiet -v
-D_GNU_SOURCE templatebug.cc -quiet -dumpbase templatebug.cc -mtune=generic
-auxbase templatebug -version -o /tmp/ccKj2izO.s
ignoring nonexistent directory
"/usr6/ausdev/32/gcc/lib/gcc/i686-pc-linux-gnu/4.4.0/../../../../i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:

/usr6/ausdev/32/gcc/lib/gcc/i686-pc-linux-gnu/4.4.0/../../../../include/c++/4.4.0

/usr6/ausdev/32/gcc/lib/gcc/i686-pc-linux-gnu/4.4.0/../../../../include/c++/4.4.0/i686-pc-linux-gnu

/usr6/ausdev/32/gcc/lib/gcc/i686-pc-linux-gnu/4.4.0/../../../../include/c++/4.4.0/backward
 /usr/local/include
 /usr6/ausdev/32/gcc/include
 /usr6/ausdev/32/gcc/lib/gcc/i686-pc-linux-gnu/4.4.0/include
 /usr6/ausdev/32/gcc/lib/gcc/i686-pc-linux-gnu/4.4.0/include-fixed
 /usr/include
End of search list.
GNU C++ (GCC) version 4.4.0 (i686-pc-linux-gnu)
        compiled by GNU C version 4.4.0, GMP version 4.2.4, MPFR version 2.4.1.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: cdc0e2c063f6091375cab171c4ed59f5
templatebug.cc: In function ‘int myfunction()’:
templatebug.cc:26: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.


-- 
           Summary: member template specialization causes ICE
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: mark at austrics dot com dot au


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40808


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2009-10-23 21:43 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-07-20  6:13 [Bug c++/40808] New: member template specialization causes ICE mark at austrics dot com dot au
2009-08-25 14:17 ` [Bug c++/40808] [4.4/4.5 regression] " bangerth at gmail dot com
2009-08-25 15:48 ` jsm28 at gcc dot gnu dot org
2009-08-31 21:52 ` mmitchel at gcc dot gnu dot org
2009-10-15 12:58 ` jakub at gcc dot gnu dot org
2009-10-23 10:58 ` dodji at gcc dot gnu dot org
2009-10-23 18:08   ` Dodji Seketeli
2009-10-23 21:33 ` dodji at gcc dot gnu dot org
2009-10-23 21:39 ` dodji at gcc dot gnu dot org
2009-10-23 21:43 ` dodji at gcc dot gnu dot org

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).