[Bug c++/15063] New: template instantiation causes internal error

ivan at sierra-da dot com gcc-bugzilla@gcc.gnu.org
Thu Apr 22 08:10:00 GMT 2004


Version: g++ (GCC) 3.3.3

 Command line: g++ -bug gcc-bug.cpp 

Output: gcc-bug.cpp: In instantiation of `HasFunc': gcc-bug.cpp:55: instantiated
from here gcc-bug.cpp:32: internal compiler error: in walk_tree, at
tree-inline.c:1764 Please submit a full bug report, with preprocessed source if
appropriate. See  for instructions. 

Explanation: By mistake I switched the order of the templates arguments when
instantiating in main(). The rest should be self-explanatory. 

Source: 

#include  class A; 
/////////////////////////////////// 
template  class IsTypeOf { 
typedef char ONE; 
typedef struct { char guts_[2]; } TWO; 
protected: template static ONE test(T); 
template static TWO test(...); 
public: enum { val = sizeof(IsTypeOf::test((C*)0)) }; 
enum { yes = val == sizeof(ONE) }; };
 
/////////////////////////////////// 
template class HasFunc { 
typedef char ONE; 
typedef struct { char guts_[2]; } TWO; 
protected: template struct has_set { typedef ONE size; }; 
template struct has_set { typedef TWO size; }; 
public: enum { val = sizeof(typename has_set::size) }; 
enum { yes = IsTypeOf::yes && val == sizeof(TWO) }; }; 

////////////////////////////////////////////////////////////////////// 
struct A { virtual void set(int ) {} virtual void set(float ) {} };
 struct B : public A { void set(int ) {} }; 
struct C { void set(int ) {} }; 

#define WRONG // #undef WRONG 
/////////////// int main() { 
#ifdef WRONG 
std::cout << "B has set(int): " << HasFunc::yes << std::endl; 
std::cout << "B has set(float): " << HasFunc::yes << std::endl; 
std::cout << "B has set(long): " << HasFunc::yes << std::endl; 
std::cout << "C has set(int): " << HasFunc::yes << std::endl; 
std::cout << "C has set(long): " << HasFunc::yes << std::endl; 
#else 
std::cout << "B has set(int): " << HasFunc::yes << std::endl; 
std::cout << "B has set(float): " << HasFunc::yes << std::endl; 
std::cout << "B has set(long): " << HasFunc::yes << std::endl; 
std::cout << "C has set(int): " << HasFunc::yes << std::endl; 
std::cout << "C has set(long): " << HasFunc::yes << std::endl; 
#endif }

-- 
           Summary: template instantiation causes internal error
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ivan at sierra-da dot com
                CC: gcc-bugs at gcc dot gnu dot org


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



More information about the Gcc-bugs mailing list