Bug 45293 - ICE in iterative_hash_template_arg, at cp/pt.c:1589
Summary: ICE in iterative_hash_template_arg, at cp/pt.c:1589
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.5.1
: P3 major
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on: 45200
Blocks:
  Show dependency treegraph
 
Reported: 2010-08-16 01:06 UTC by David Fang
Modified: 2010-09-07 07:12 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2010-08-17 17:41:03


Attachments
unreduced test case triggering ICE (219.47 KB, application/x-bzip2)
2010-08-16 01:07 UTC, David Fang
Details
delta reduced, day 2 (103.50 KB, application/x-bzip)
2010-08-17 17:26 UTC, David Fang
Details
test case, semi-reduced, day 3 (53.41 KB, application/x-bzip2)
2010-08-18 16:30 UTC, David Fang
Details
test case, day 3b (5.09 KB, application/x-bzip)
2010-08-18 20:13 UTC, David Fang
Details

Note You need to log in before you can comment on or make changes to this bug.
Description David Fang 2010-08-16 01:06:38 UTC
with g++-4.5.1 (powerpc-apple-darwin8):
internal compiler error: in iterative_hash_template_arg, at cp/pt.c:1589
with the attached unreduced test case, which I'm delta-reducing at the moment...

never tested against 4.5.0.  
This code compiled with 4.4.x and earlier, which leads me to believe that it is valid, but I cannot be certain.
Comment 1 David Fang 2010-08-16 01:07:56 UTC
Created attachment 21487 [details]
unreduced test case triggering ICE
Comment 2 David Fang 2010-08-16 06:11:24 UTC
still reducing...

command to reproduce (passed to multidelta):

#!/bin/sh
g++-fsf-4.5 -pipe -ansi -pedantic-errors -Wold-style-cast -Woverloaded-virtual -W -Wextra -Wall -Wundef -Wshadow -Wno-unused-parameter -Wpointer-arith -Wcast-qual -Wcast-align -Wconversion -Werror -std=c++0x -Wno-error=conversion -g -O3 -Wno-long-long -o footprint.o -c footprint.ii > footprint.err 2>&1
grep -q "internal compiler error: in iterative_hash_template_arg, at cp/pt.c:1589" footprint.err
Comment 3 Richard Biener 2010-08-16 10:07:38 UTC
I get

/space/rguenther/install/gcc-4.5.1/bin/g++ -S -o /dev/null footprint.ii -std=c++0x -Wfatal-errors
In file included from ../../../src/Object/inst/instance_collection_pool_bundle_footprint.tcc:14:0,
                 from ../../../src/Object/def/footprint.cc:32:
../../../src/Object/inst/instance_scalar.h: In instantiation of 'HAC::entity::instance_array<HAC::entity::process_tag, 0ul>':
../../../src/Object/inst/instance_collection_pool_bundle.h:49:7:   instantiated from 'HAC::entity::instance_collection_pool_wrapper<HAC::entity::instance_array<HAC::entity::process_tag, 0ul> >'
../../../src/Object/inst/instance_collection_pool_bundle.h:135:72:   instantiated from 'HAC::entity::instance_collection_pool_bundle<HAC::entity::process_tag>'
../../../src/Object/def/footprint.cc:619:25:   instantiated from here
../../../src/Object/inst/instance_scalar.h:138:7: internal compiler error: tree check: accessed elt 2 of tree_vec with 1 elts in tsubst, at cp/pt.c:10113
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

which is likely the reason for the error you are seeing.

Which eventually makes it a dup of PR45200.
Comment 4 David Fang 2010-08-17 17:26:45 UTC
Created attachment 21507 [details]
delta reduced, day 2

Slowly being reduced by delta, day 2 ...
Comment 5 H.J. Lu 2010-08-17 17:41:03 UTC
It is caused by revision 145440:

http://gcc.gnu.org/ml/gcc-cvs/2009-04/msg00060.html
Comment 6 David Fang 2010-08-18 16:30:59 UTC
Created attachment 21512 [details]
test case, semi-reduced, day 3

day 3 of reducing, 4.5k lines
Comment 7 David Fang 2010-08-18 20:13:37 UTC
Created attachment 21515 [details]
test case, day 3b

yet smaller
Comment 8 David Fang 2010-08-18 22:05:09 UTC
reduced test case (manually reduced after delta):

===========================================================
typedef long unsigned int size_t;
template <class T> struct never_ptr {
T* ptr;
T* operator -> () const throw() {
return ptr;
}  
};  
namespace HAC {
template <class> class instance_collection_pool_bundle;
template <class Tag> class footprint_base {
typedef instance_collection_pool_bundle<Tag>      collection_pool_bundle_type;
protected:  const never_ptr<collection_pool_bundle_type> collection_pool_bundle;
}; 
struct process_tag;
template <class Tag> class instance_collection;
template <class> struct class_traits;
template <class Tag> class instance_alias_info;
}   
namespace std {
template <class T> struct default_vector {
typedef size_t type;
};  
}  
namespace HAC {
class footprint : private footprint_base<process_tag> {
void operator [] ( const size_t ) const;
};  
class physical_instance_collection;
template <class, size_t> class instance_array;
typedef instance_collection<process_tag>  process_instance_collection;
typedef instance_alias_info<process_tag> process_instance_alias_info;
template <class> class general_collection_type_manager;
template <> struct class_traits<process_tag> {
typedef process_tag tag_type;
typedef process_instance_alias_info instance_alias_info_type;
typedef process_instance_collection instance_collection_generic_type;
typedef physical_instance_collection instance_collection_parent_type;
typedef general_collection_type_manager<tag_type>      collection_type_manager_parent_type;
}; 
class instance_collection_base {
}; 
class physical_instance_collection : public instance_collection_base   {
}; 
template <class Tag> class collection_interface :  public class_traits<Tag>::instance_collection_parent_type {
};  
template <class Tag> class instance_collection :  public collection_interface<Tag>,  public class_traits<Tag>::collection_type_manager_parent_type {
public:  typedef class_traits<Tag> traits_type;
typedef typename traits_type::instance_alias_info_type       instance_alias_info_type;
typedef never_ptr<const instance_alias_info_type>      const_instance_alias_info_ptr_type;
}; 
template <class Tag> class general_collection_type_manager {
}; 
template <class T> class instance_collection_pool_wrapper {
public:  typedef T collection_type;
typedef typename collection_type::traits_type::tag_type       tag_type;
}; 
template <class Tag> struct instance_collection_pool_bundle : public instance_collection_pool_wrapper<instance_array<Tag, 0> > {
void lookup_collection(void) const;
};
template <class Tag, size_t D> class instance_array : public instance_collection<Tag> {
public:  typedef class_traits<Tag> traits_type;
typedef typename traits_type::instance_collection_generic_type        parent_type; 
typedef typename parent_type::const_instance_alias_info_ptr_type      const_instance_alias_info_ptr_type;
void get_all_aliases(typename std::default_vector<const_instance_alias_info_ptr_type>::type&) const;
}; 
template <class Tag> class instance_array<Tag,0> : public instance_collection<Tag> {
public:  typedef class_traits<Tag> traits_type;
typedef typename traits_type::instance_collection_generic_type        parent_type; 
typedef typename parent_type::const_instance_alias_info_ptr_type      const_instance_alias_info_ptr_type;
void get_all_aliases(typename std::default_vector<const_instance_alias_info_ptr_type>::type&) const;
}; 
void footprint::operator [] ( const size_t ) const {
footprint_base<process_tag>::collection_pool_bundle->lookup_collection();
}   
}
===========================================================

This should be a valid test case, passes g++-4.0.1.

reducing script:

#!/bin/sh -e
# must be valid for g++-4.0.1! (powerpc-apple-darwin8)
g++ -o footprint.o -c footprint.ii > /dev/null 2>&1
# then fail specifically with ICE
g++-fsf-4.5 -o footprint.o -c footprint.ii > footprint.err 2>&1 || :
grep -q "internal compiler error: in iterative_hash_template_arg, at cp/pt.c:1589" footprint.err

keywords: ICE-on-valid-code
Comment 9 Dodji Seketeli 2010-09-06 18:44:41 UTC
Subject: Bug 45293

Author: dodji
Date: Mon Sep  6 18:44:23 2010
New Revision: 163929

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=163929
Log:
Patch PR c++/45200

    Fix PR c++/45200, c++/45293, c++/45558

gcc/cp/Changelog:
	PR c++/45200
	PR c++/45293
	PR c++/45558
	* tree.c (strip_typedefs): Strip typedefs from the context of
	TYPENAME_TYPEs.

gcc/testsuite/ChangeLog:
	PR c++/45200
	PR c++/45293
	PR c++/45558
	* g++.dg/template/typedef34.C: New test.
	* g++.dg/template/typedef35.C: New test.

Added:
    trunk/gcc/testsuite/g++.dg/template/typedef34.C
    trunk/gcc/testsuite/g++.dg/template/typedef35.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/tree.c
    trunk/gcc/cp/typeck.c
    trunk/gcc/testsuite/ChangeLog

Comment 10 Dodji Seketeli 2010-09-06 18:50:02 UTC
Subject: Bug 45293

Author: dodji
Date: Mon Sep  6 18:49:46 2010
New Revision: 163930

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=163930
Log:
Patch PR c++/45200

    Fix PR c++/45200, c++/45293, c++/45558

gcc/cp/Changelog:
	PR c++/45200
	PR c++/45293
	PR c++/45558
	* tree.c (strip_typedefs): Strip typedefs from the context of
	TYPENAME_TYPEs.

gcc/testsuite/ChangeLog:
	PR c++/45200
	PR c++/45293
	PR c++/45558
	* g++.dg/template/typedef34.C: New test.
	* g++.dg/template/typedef35.C: New test.

Added:
    branches/gcc-4_5-branch/gcc/testsuite/g++.dg/template/typedef34.C
    branches/gcc-4_5-branch/gcc/testsuite/g++.dg/template/typedef35.C
Modified:
    branches/gcc-4_5-branch/gcc/cp/ChangeLog
    branches/gcc-4_5-branch/gcc/cp/tree.c
    branches/gcc-4_5-branch/gcc/cp/typeck.c
    branches/gcc-4_5-branch/gcc/testsuite/ChangeLog

Comment 11 Dodji Seketeli 2010-09-07 07:12:48 UTC
Fixed in 4.5.2 and trunk (4.6)