Bug 56395 - [4.7/4.8 Regression] ICE, Segmentation fault in tsubst
Summary: [4.7/4.8 Regression] ICE, Segmentation fault in tsubst
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.7.3
: P1 normal
Target Milestone: 4.7.3
Assignee: Jason Merrill
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2013-02-19 14:16 UTC by Matthias Klose
Modified: 2013-02-23 01:58 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work: 4.7.2
Known to fail:
Last reconfirmed: 2013-02-19 00:00:00


Attachments
preprocessed source (259.86 KB, application/x-xz)
2013-02-19 14:16 UTC, Matthias Klose
Details
pr56395.ii (3.98 KB, text/plain)
2013-02-19 23:32 UTC, Jakub Jelinek
Details
pr56395.ii (2.02 KB, text/plain)
2013-02-20 11:38 UTC, Jakub Jelinek
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Matthias Klose 2013-02-19 14:16:11 UTC
works with 4.7.2, fails with 4.7 20130215 and trunk 20130217.

$ g++ -c Platform.ii
./openvdb/tree/TreeIterator.h:433:40: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
Comment 1 Matthias Klose 2013-02-19 14:16:53 UTC
Created attachment 29494 [details]
preprocessed source
Comment 2 Richard Biener 2013-02-19 14:29:21 UTC
Confirmed.

./openvdb/tree/TreeIterator.h:433:40: internal compiler error: tree check: accessed elt 4 of tree_vec with 3 elts in tsubst, at cp/pt.c:11228
0xf2f8a4 tree_vec_elt_check_failed(int, int, char const*, int, char const*)
        /space/rguenther/src/svn/trunk/gcc/tree.c:9131
0x5afeb9 tree_vec_elt_check(tree_node*, int, char const*, int, char const*)
        /space/rguenther/src/svn/trunk/gcc/tree.h:3869
0x657334 tsubst(tree_node*, tree_node*, int, tree_node*)
        /space/rguenther/src/svn/trunk/gcc/cp/pt.c:11228
0x65cd34 tsubst_copy
        /space/rguenther/src/svn/trunk/gcc/cp/pt.c:12463
Comment 3 Jakub Jelinek 2013-02-19 15:05:49 UTC
Started with http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=189298
Reducing.
Comment 4 Jakub Jelinek 2013-02-19 23:32:15 UTC
Created attachment 29505 [details]
pr56395.ii

Somewhat reduced testcase (after 9 hours of delta, still > 20KB).
Comment 5 Jakub Jelinek 2013-02-20 11:38:05 UTC
Created attachment 29508 [details]
pr56395.ii

Some more reduced testcase, still almost 9KB.  Boost testcases are really hard to reduce :(.
Comment 6 Markus Trippelsdorf 2013-02-20 12:19:47 UTC
A little bit further reduced:

template < typename T > struct I
{
  typedef T type;
};
template < typename T > struct F
{
  typedef T type;
};
template < typename ChildType > struct H
{
  typedef ChildType ChildNodeType;
    template < typename RootNodeT > struct A
  {
    typedef RootNodeT NodeType;
    typedef typename F < NodeType >::type NonConstNodeType;
  };
  typedef A < H > ChildOnCIter;
};
template < bool > struct C;
template <> struct C <false >
{
  template < typename Sequence > struct G
  {
    typedef typename Sequence::tag type;
  };
};
template < typename Sequence > struct O:C < 0 >::G < Sequence >
{
};
template < typename > struct W;
template < typename Sequence > struct P:W < typename O <
  Sequence >::type >::template X < Sequence >
{
};
template < typename > struct L;
template < typename Sequence,
  typename T > struct Q:L < typename O < Sequence >::type >
                        ::template X < Sequence, T >
{
};
template <> struct W <int >
{
  template < typename Vector > struct X:I < Vector >
  {
  };
};
template < typename Base > struct R:Base
{
};
template < typename = int > struct V;
template <> struct V <>
{
  typedef int tag;
};
struct S:R < V <> >
{
};
template < typename HeadT, int > struct J
{
  typedef typename J < typename HeadT::ChildNodeType, 1 >::Type SubtreeT;
  typedef typename Q < SubtreeT, HeadT >::type Type;
};
template < typename HeadT > struct J <HeadT, 0 >
{
  typedef S Type;
};
template < typename > struct IterTraits
{
  template < typename OtherNodeT > struct K
  {
    typedef OtherNodeT Type;
  };
};
template < typename PrevItemT, typename NodeVecT, int > struct B
{
  typedef typename PrevItemT::IterT PrevIterT;
  typedef typename P < NodeVecT >::type _NodeT;
  typedef typename IterTraits < PrevIterT >::template K < _NodeT >::Type IterT;
    IterTraits < IterT > ITraits;
};
template < typename PrevItemT, typename NodeVecT > struct B <PrevItemT,
  NodeVecT, 0 >
{
  typedef typename PrevItemT::IterT PrevIterT;
  typedef typename P < NodeVecT >::type _NodeT;
  typedef typename IterTraits < PrevIterT >::template K < _NodeT >::Type IterT;
    IterTraits < IterT > ITraits;
};
template < typename RootChildOnIterT > struct N
{
  typedef RootChildOnIterT RootIterT;
  typedef typename RootIterT::NonConstNodeType NCRootNodeT;
  typedef typename J < NCRootNodeT, 0 >::Type InvTreeT;
  struct M
  {
    typedef RootIterT IterT;
  };
    B < M, InvTreeT, 0 > mIterList;
};
template < typename T > struct D
{
  N < typename T::ChildOnCIter > LeafCIter;
};
D < H < int > >a;
Comment 7 Markus Trippelsdorf 2013-02-20 12:40:01 UTC
Still more reduced:

template<typename T>struct I
{
  typedef T type;
};
struct H
{
  typedef int ChildOnCIter;
};
template<bool>struct C;
template<>struct C<false>
{
  template<typename Sequence>struct G
  {
    typedef typename Sequence::tag type;
  };
};
template<typename Sequence>struct O : C<0>::G<Sequence>
{};
template<typename>struct W;
template<typename Sequence>struct P : W
        <typename O <Sequence>::type>::template X<Sequence>
{};
template<>struct W<int>
{
  template<typename Vector>struct X : I<Vector>
  {};
};
template<typename Base>struct R : Base
{};
template<typename = int>struct V;
template<>struct V<>
{
  typedef int tag;
};
struct S : R<V<> >
{};
template<typename>struct IterTraits
{
  template<typename OtherNodeT>struct K
  {
    typedef OtherNodeT Type;
  };
};
template<typename PrevItemT, typename NodeVecT, int>struct B
{
  typedef typename PrevItemT::IterT  PrevIterT;
  typedef typename P<NodeVecT>::type _NodeT;
  typedef typename IterTraits<PrevIterT>::template K< _NodeT>::Type IterT;
  IterTraits<IterT>ITraits;
};
template<typename PrevItemT, typename NodeVecT>struct B<PrevItemT, NodeVecT,0>
{
  typedef typename PrevItemT::IterT  PrevIterT;
  typedef typename P<NodeVecT>::type _NodeT;
  typedef typename IterTraits<PrevIterT>::template K<
      _NodeT>::Type IterT;
  IterTraits<IterT> ITraits;
};
template<typename RootChildOnIterT>struct N
{
  typedef RootChildOnIterT RootIterT;
  struct M
  {
    typedef RootIterT IterT;
  };
  B<M, S, 0>mIterList;
};
template<typename T>struct D
{
  N<typename T::ChildOnCIter>LeafCIter;
};
D<H> a;
Comment 8 Jason Merrill 2013-02-22 22:24:05 UTC
Author: jason
Date: Fri Feb 22 22:23:56 2013
New Revision: 196228

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=196228
Log:
	PR c++/56395
	* tree.c (strip_typedefs): Strip typedefs from TYPENAME_TYPE template
	args.

Added:
    trunk/gcc/testsuite/g++.dg/template/typename19.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/tree.c
Comment 9 Jason Merrill 2013-02-22 22:26:19 UTC
Author: jason
Date: Fri Feb 22 22:26:08 2013
New Revision: 196232

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=196232
Log:
	PR c++/56395
	* tree.c (strip_typedefs): Strip typedefs from TYPENAME_TYPE template
	args.

Added:
    branches/gcc-4_7-branch/gcc/testsuite/g++.dg/template/typename19.C
Modified:
    branches/gcc-4_7-branch/gcc/cp/ChangeLog
    branches/gcc-4_7-branch/gcc/cp/tree.c
Comment 10 Jason Merrill 2013-02-23 01:58:54 UTC
Fixed.