Bug 16706 - [3.4/4.0 Regression] ICE in finish_member_declaration, at cp/semantics.c:2126
Summary: [3.4/4.0 Regression] ICE in finish_member_declaration, at cp/semantics.c:2126
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.4.1
: P2 critical
Target Milestone: 3.4.2
Assignee: Kriang Lerdsuwanakij
URL:
Keywords: ice-on-valid-code, monitored, patch
Depends on:
Blocks:
 
Reported: 2004-07-25 15:25 UTC by Debian GCC Maintainers
Modified: 2004-10-30 21:11 UTC (History)
4 users (show)

See Also:
Host: i486-linux
Target: i486-linux
Build: i486-linux
Known to work: 3.3.4
Known to fail: 3.4.0 4.0.0
Last reconfirmed: 2004-07-26 00:54:01


Attachments
preprocessed source (74.07 KB, application/x-gzip)
2004-07-25 15:27 UTC, Debian GCC Maintainers
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Debian GCC Maintainers 2004-07-25 15:25:40 UTC
[forwarded from http://bugs.debian.org/261051]

seen with 3.4.1 and HEAD 20040717, configured with
--enable-libstdc++-allocator=mt. ok with 3.3.4 (configured with standard
allocator). Not yet checked with the default configuration in 3.4 and HEAD.

    Matthias


$ gcc-3.4 -c oggfile.ii 
/usr/include/c++/3.4/ext/mt_allocator.h: In instantiation of
`__gnu_cxx::__mt_alloc<_Tp>':
/usr/include/c++/3.4/bits/allocator.h:81:   instantiated from
`std::allocator<_CharT>'
/usr/include/c++/3.4/bits/stl_list.h:295:   instantiated from
`std::_List_base<T, std::allocator<_CharT> >'
/usr/include/c++/3.4/bits/stl_list.h:388:   instantiated from `std::list<T,
std::allocator<_CharT> >'
/src/kde/kdesupport/taglib/toolkit/tlist.h:53:   instantiated from `TagLib::List<T>'
/src/kde/kdesupport/taglib/toolkit/tlist.tcc:67:   instantiated from
`TagLib::List<T>::ListPrivate<TP*>::ListPrivate() [with TP = TagLib::Ogg::Page,
T = TagLib::Ogg::Page*]'
/src/kde/kdesupport/taglib/toolkit/tlist.tcc:90:   instantiated from
`TagLib::List<T>::List() [with T = TagLib::Ogg::Page*]'
/src/kde/kdesupport/taglib/ogg/oggfile.cpp:42:   instantiated from here
/usr/include/c++/3.4/ext/mt_allocator.h:120: internal compiler error: in
finish_member_declaration, at cp/semantics.c:2101
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
Comment 1 Debian GCC Maintainers 2004-07-25 15:27:02 UTC
Created attachment 6826 [details]
preprocessed source
Comment 2 Andrew Pinski 2004-07-25 18:07:44 UTC
Confirmed but I have not reduced it yet.
Even though the mt allocator sources is included and this might not show up with the standard 
allocated, this is a bug in the C++ front-end and not libstdc++ and still can be reproduced using the 
preprocessed source.
Comment 3 Wolfgang Bangerth 2004-07-26 00:54:00 UTC
I can't seem to get it smaller than this: 
------------------------ 
template <typename> struct B { 
    B() throw() {} 
    struct S { }; 
    static int i; 
    typedef unsigned short int dummy; 
}; 
 
template <typename _Tp> 
struct allocator: B<_Tp> { 
    template<typename _Tp1> struct rebind 
    { typedef allocator<_Tp1> other; }; 
}; 
 
template<typename T, typename> 
struct X { 
    typename allocator<T>::template rebind<int>::other i; 
    typedef int* dummy; 
}; 
 
template <class T> class A { 
    typedef typename X<T,allocator<T> >::dummy dummy; 
    template <class TP> class XWrapper; 
}; 
 
 
template <class T> 
template <class TP> struct A<T>::XWrapper<TP *> 
{ 
    XWrapper() {} 
    X<int,allocator<int> > x; 
}; 
 
template class A<int>::XWrapper<int *>; 
--------------------------------- 
 
This crashes both 3.4.x and mainline, but not 3.3.x: 
 
x/gg> /home/bangerth/bin/gcc-3.3*/bin/c++ -c x.cc 
 
x/gg> /home/bangerth/bin/gcc-3.4*/bin/c++ -c x.cc 
x.cc: In instantiation of `allocator<T>::rebind<int>': 
x.cc:16:   instantiated from `X<T, allocator<T> >' 
x.cc:21:   instantiated from `A<T>' 
x.cc:29:   instantiated from `A<T>::XWrapper<TP*>::XWrapper() [with TP = int, 
T = int]' 
x.cc:33:   instantiated from here 
x.cc:11: internal compiler error: in instantiate_class_template, at 
cp/pt.c:5404 
Please submit a full bug report, 
with preprocessed source if appropriate. 
See <URL:http://gcc.gnu.org/bugs.html> for instructions. 
 
x/gg> /home/bangerth/bin/gcc-3.5*/bin/c++ -c x.cc 
x.cc: In instantiation of `allocator<T>::rebind<int>': 
x.cc:16:   instantiated from `X<T, allocator<T> >' 
x.cc:21:   instantiated from `A<T>' 
x.cc:29:   instantiated from `A<T>::XWrapper<TP*>::XWrapper() [with TP = int, 
T = int]' 
x.cc:33:   instantiated from here 
x.cc:11: internal compiler error: in instantiate_class_template, at 
cp/pt.c:5440 
Please submit a full bug report, 
with preprocessed source if appropriate. 
See <URL:http://gcc.gnu.org/bugs.html> for instructions. 
 
W. 
Comment 4 Volker Reichelt 2004-07-26 03:18:00 UTC
Here's something slightly smaller:

===============================================================
template<typename> struct A 
{
    A();
    template<typename> struct X {};
};

template<typename T> struct B
{
    typename A<T>::template X<int> x;
    template<typename> struct C;
};

template<typename T> template<typename U> struct B<T>::C<U*>
{
    C() {}
    A<int> a;
};

template struct B<int>::C<int*>;
===============================================================

Note that the ICE in Wolfgang's and this example happens in a different
place than the original example.
Comment 5 Andrew Pinski 2004-07-29 14:40:22 UTC
Volker's reduced code
: Search converges between 2003-01-15-trunk (#165) and 2003-01-17-trunk (#166).

Wolfgang's reduced code
: Search converges between 2003-10-17-trunk (#379) and 2003-10-18-trunk (#380).

So they look like two different bugs.
Comment 6 Wolfgang Bangerth 2004-07-29 14:50:33 UTC
Andrew: I get an ICE in exactly the same position for both Volker's 
and my testcase. Are you sure they started at different times? Or 
did you mean that you compared one of our testcases with the original 
one? 
 
W. 
Comment 7 Kriang Lerdsuwanakij 2004-08-01 15:08:24 UTC
Look like something I broke.  I think a call to dependent_type_p
is missing somewhere.
Comment 8 Volker Reichelt 2004-08-02 20:38:54 UTC
> Volker's reduced code
> : Search converges between 2003-01-15-trunk (#165) and 2003-01-17-trunk
(#166).
> 
> Wolfgang's reduced code
> : Search converges between 2003-10-17-trunk (#379) and 2003-10-18-trunk
(#380).
> 
> So they look like two different bugs.

I still think this is the same underlying bug:
a) I reduced Wolfgang's version to come up with mine.
b) My example starts with an ICE in
     cxx_incomplete_type_diagnostic, at cp/typeck2.c:278
   which changed to
     instantiate_class_template, at cp/pt.c:5440
   the day Wolfgang's testcase started crashing the compiler.

Btw, I've got another reduced example - this time the crash is in the same
spot as with the original example. For this one I also get
: Search converges between 2003-01-15-trunk (#165) and 2003-01-17-trunk (#166).

===============================================================================
template<typename> struct A
{
    struct X;
    struct Y;
};

template<typename T> struct B
{
    T t;
    B();
};

template<typename T> struct C
{
    B<A<T> > b;
    template<typename> struct D;
};

template<typename T> template<typename U> struct C<T>::D<U*>
{
    B<A<T> > b;
    D() {}
};

template struct C<int>::D<int*>;
===============================================================================
Comment 9 Volker Reichelt 2004-08-02 21:06:35 UTC
Kriang, thanks for taking the blame, but I think you're innocent in this case.
The trouble starts with Mark's patch
  http://gcc.gnu.org/ml/gcc-cvs/2003-01/msg00660.html
Comment 10 Kriang Lerdsuwanakij 2004-08-03 15:25:44 UTC
Patch submitted:

  http://gcc.gnu.org/ml/gcc-patches/2004-08/msg00151.html
Comment 11 André Wöbbeking 2004-08-10 20:27:52 UTC
(In reply to comment #10) 
> Patch submitted: 
>  
>   http://gcc.gnu.org/ml/gcc-patches/2004-08/msg00151.html 
 
is it already applied? 
 
Comment 12 Kriang Lerdsuwanakij 2004-08-16 15:49:33 UTC
No, it's still waiting for approval.
Comment 13 Mark Mitchell 2004-08-23 19:23:30 UTC
This patch is OK, please apply.
Comment 14 CVS Commits 2004-08-24 14:13:59 UTC
Subject: Bug 16706

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	lerdsuwa@gcc.gnu.org	2004-08-24 14:13:50

Modified files:
	gcc/cp         : ChangeLog search.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/template: crash21.C crash22.C 

Log message:
	PR c++/16706
	* search.c (friend_accessible_p): Increment processing_template_decl
	when deal with TEMPLATE_DECL of SCOPE.
	
	* g++.dg/template/crash21.C: New test.
	* g++.dg/template/crash22.C: Likewise.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4298&r2=1.4299
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/search.c.diff?cvsroot=gcc&r1=1.309&r2=1.310
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.4180&r2=1.4181
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/crash21.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/crash22.C.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 16 Kriang Lerdsuwanakij 2004-08-24 14:36:02 UTC
Fixed in the mainline and 3.4 branch.
Comment 17 Kriang Lerdsuwanakij 2004-08-24 14:36:41 UTC
Fixed.