Bug 33239 - [4.1/4.2 Regression] internal compiler error in instantiate_class_template, at cp/pt.c:5666
Summary: [4.1/4.2 Regression] internal compiler error in instantiate_class_template, a...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.1.2
: P1 major
Target Milestone: 4.1.3
Assignee: Jason Merrill
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2007-08-29 21:54 UTC by Masse Nicolas
Modified: 2007-09-27 02:18 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work: 3.3.3 4.3.0
Known to fail: 4.1.1
Last reconfirmed: 2007-09-23 18:24:07


Attachments
Complete sources tree where the problem happens (79.05 KB, application/bzip2)
2007-08-29 21:57 UTC, Masse Nicolas
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Masse Nicolas 2007-08-29 21:54:20 UTC
All is in the title. Here is the complete output I have (my system is in french):
g++ -DHAVE_CONFIG_H -I. -I.. -I ../src    -g -O2 -MT sample1.o -MD -MP -MF .deps/sample1.Tpo -c -o sample1.o sample1.cpp
../src/tuple.hpp: In instantiation of 'yactl::tuple_impl<int, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >::append<yactl::null_type, int, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >':
../src/tuple.hpp:105:   instantiated from 'yactl::tuple<int, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, yactl::null_type, yactl::null_type, yactl::null_type, yactl::null_type, yactl::null_type, yactl::null_type, yactl::null_type, yactl::null_type, yactl::null_type, yactl::null_type, yactl::null_type, yactl::null_type, yactl::null_type, yactl::null_type>'
sample1.cpp:37:   instantiated from here
../src/tuple.hpp:40: erreur interne du compilateur: dans instantiate_class_template, à cp/pt.c:5666
Veuillez soumettre un rapport complet d'anomalies,
avec le source pré-traité si nécessaire.
Consultez <URL:http://gcc.gnu.org/bugs.html> pour plus de détail.
Comment 1 Masse Nicolas 2007-08-29 21:57:29 UTC
Created attachment 14135 [details]
Complete sources tree where the problem happens
Comment 2 Andrew Pinski 2007-09-01 00:40:06 UTC
I get errors before the ICE:
../src/typelist.hpp:49: error: 'uint' has not been declared
Comment 3 Andrew Pinski 2007-09-01 00:42:37 UTC
But after fixing the errors, I still get the ICE so reducing.
Comment 4 Andrew Pinski 2007-09-01 01:29:27 UTC
Reduced testcase:
struct null_type {typedef null_type base_type;};
template<typename T1, typename T2=null_type>
struct tuple_impl
{
 template<typename U, typename V=T1>
 struct append{
  typedef tuple_impl<U, tuple_impl<V, null_type> > type;
 };
 template<typename V>
 struct append<null_type, V>{
  typedef tuple_impl <V, null_type> type;
 };
  int data;
};
template<typename T1 = null_type,typename T2 = null_type,typename T3 = null_type,typename T4 = null_type,typename T5 = null_type,typename T6 = null_type,typename T7 = null_type,typename T8 = null_type,typename T9 = null_type,typename T10 = null_type,typename T11 = null_type,typename T12 = null_type,typename T13 = null_type,typename T14 = null_type,typename T15 = null_type>
class tuple : public tuple_impl<T1, null_type>::template append<T2>::type::template append<T3>::type::template append<T4>::type::template append<T5>::type::template append<T6>::type::template append<T7>::type::template append<T8>::type::template append<T9>::type::template append<T10>::type::template append<T11>::type::template append<T12>::type::template append<T13>::type::template append<T14>::type::template append<T15>::type
{
 using tuple_impl<T1, null_type>::template append<T2>::type::template append<T3>::type::template append<T4>::type::template append<T5>::type::template append<T6>::type::template append<T7>::type::template append<T8>::type::template append<T9>::type::template append<T10>::type::template append<T11>::type::template append<T12>::type::template append<T13>::type::template append<T14>::type::template append<T15>::type::data;
};
tuple<int, int>  my_tuple;
Comment 5 Paolo Carlini 2007-09-08 02:22:30 UTC
Now the ICE is at line 6586. Can be triggered with this smaller snippet:

struct null_type;

template<typename T1, typename T2>
struct tuple_impl
{
  template<typename U>
  struct append
  {
    typedef tuple_impl<U, null_type> type;
  };

  int data;
};

template<typename T1, typename T2>
class tuple
: public tuple_impl<T1, null_type>::template append<T1>::type
{
  using tuple_impl<T1, null_type>::template append<T1>::type::data;
};

tuple<int, int>  my_tuple;

---------

Note that if I remove the now redundant template parameter T2 of tuple and instantiate with typle<int>, we get immediately a bit of additional info:

33239_p2.C: In instantiation of ‘tuple<int>’:
33239_p2.C:22:   instantiated from here
33239_p2.C:19: internal compiler error: tree check: accessed elt 2 of tree_vec with 1 elts in tsubst, at cp/pt.c:8601
Comment 6 Jason Merrill 2007-09-24 20:54:47 UTC
Subject: Bug 33239

Author: jason
Date: Mon Sep 24 20:54:34 2007
New Revision: 128725

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=128725
Log:
        PR c++/33239
        * pt.c (resolve_typename_type): Don't look things up in the original
        template if it would mean losing template arguments.

Added:
    trunk/gcc/testsuite/g++.dg/template/memtmpl3.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/pt.c

Comment 7 Jason Merrill 2007-09-24 20:56:42 UTC
Fixed for 4.3.0.