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]

[Bug c++/29698] New: ICE on sizeof(<template type>) inside a template func


My OS is Fedora Core 6 - I'm using the compiler, that ships with it.

It crashes on this code:

===========================================
#include <iostream>
#include <algorithm>

template <typename INT>
int foo(INT m)
{
        return sizeof(std::pair<int, int>);
}

int main(void)
{
        std::cout << foo((int)0) << std::endl;
        return 0;
}
=================================================

The crash occurs on the return of foo(). In fact, it occurs anytime where
sizeof(std::pair<int,int>); is used for whatever reason.

The crash says:
========================================================
ice1.cpp: In function ?int foo(INT)?:
ice1.cpp:7: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate...
========================================================

It's OK when foo() is non-template.
It's OK when you generate an instance of this type and sizeof() the instance
instead. ("std::pair<int,int> dummy; sizeof(dummy);" works)
It's OK under g++ 3.4 and 3.3 (32-bit though - don't have other x86_64 to
test).

Ouput of g++ -v:
=========================================================
Using built-in specs.
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--enable-checking=release --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-libgcj-multifile
--enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk
--disable-dssi --enable-plugin
--with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --with-cpu=generic
--host=x86_64-redhat-linux
Thread model: posix
gcc version 4.1.1 20061011 (Red Hat 4.1.1-30)
===================================================================


-- 
           Summary: ICE on sizeof(<template type>) inside a template func
           Product: gcc
           Version: 4.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: skalaren_alpinist at abv dot bg
  GCC host triplet: x86_64-redhat-linux


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]