[Bug c++/39444] New: ICE caused by default template argument

tortoise_74 at yahoo dot co dot uk gcc-bugzilla@gcc.gnu.org
Thu Mar 12 17:20:00 GMT 2009


Compiling the following code causes an internal compiler error on both:
  gcc (GCC) 4.1.2 20061115 (prerelease) (SUSE Linux)
&
  gcc (GCC) 4.1.2 20071124 (Red Hat 4.1.2-42)

#include <string>
#include <typeinfo>

template<class FILTER, const std::string& filterName = std::string("") >
class Filter
{
public:
   virtual const std::string& getFilterName() const
   {
      static const std::string name = filterName;
      return name;
   }
};

void breakMe() 
{
   Filter<int> boo;
}

The output is:

g++    -c -o template.o template.cpp
template.cpp: In instantiation of $-1òøFilter<int, std::basic_string<char,
std::char_traits<char>, std::allocator<char> >(((const char*)""), ((const
std::allocator<char>&)((const std::allocator<char>*)(&
std::allocator<char>()))))>òù:
template.cpp:18:   instantiated from here
template.cpp:7: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.

Using a typeid in place of std::string("") for the default causes a more
cryptic

g++    -c -o template.o template.cpp
template.cpp: In instantiation of ‘Filter<int, ((const std::type_info*)(&
_ZTIi))->const char* std::type_info::name()>Â’:
template.cpp:45:   instantiated from here
template.cpp:34: sorry, unimplemented: call_expr cannot be mangled due to a
defect in the C++ ABI
template.cpp:34: sorry, unimplemented: call_expr cannot be mangled due to a
defect in the C++ ABI
template.cpp:45: sorry, unimplemented: call_expr cannot be mangled due to a
defect in the C++ ABI
template.cpp:45: sorry, unimplemented: call_expr cannot be mangled due to a
defect in the C++ ABI
template.cpp: In member function ‘const std::string& Filter<FILTER,
filterName>::getFilterName() const [with FILTER = int, const std::string&
filterName = ((const std::type_info*)(& _ZTIi))->std::type_info::name()]Â’:
template.cpp:45:   instantiated from here
template.cpp:38: sorry, unimplemented: call_expr cannot be mangled due to a
defect in the C++ ABI


-- 
           Summary: ICE caused by default template argument
           Product: gcc
           Version: 4.1.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: tortoise_74 at yahoo dot co dot uk
 GCC build triplet: x86_64-linux-redhat
  GCC host triplet: x86_64-linux-redhat
GCC target triplet: x86_64-linux-redhat


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



More information about the Gcc-bugs mailing list