Bug 28827 - [4.0 Regression] ICE with nested template friend
Summary: [4.0 Regression] ICE with nested template friend
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.0.3
: P3 normal
Target Milestone: 4.0.4
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-invalid-code
Depends on:
Blocks:
 
Reported: 2006-08-24 00:53 UTC by Johan Euphrosine
Modified: 2006-10-12 01:47 UTC (History)
2 users (show)

See Also:
Host: i486-linux-gnu
Target: i486-linux-gnu
Build: i486-linux-gnu
Known to work:
Known to fail: 3.0.4 4.0.0
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Johan Euphrosine 2006-08-24 00:53:33 UTC
template<typename T>
struct Base : T
{
  typedef T Derived;
};

struct A
{
  template<typename T>
  friend struct Base<T>::Derived::Crash;
// nested.cpp:10: internal compiler error: in lookup_member, at cp/search.c:1213
// ICE with g++-4.0.3
// PASS with g++-3.4.6
};
Comment 1 Andrew Pinski 2006-08-24 01:00:38 UTC
4.2.0 rejects the code:
t.cc:10: error: 'Crash' is not a member of 'T'

This code is invalid.
3.3 gave:
t.cc:10: error: typename type `typename Base<T>::Derived::Crash' declared
   `friend'

ICC gives:
t.cc(10): error: a qualified friend template declaration must refer to a specific previously declared template
    friend struct Base<T>::Derived::Crash;
                                    ^

compilation aborted for t.cc (code 2)

Comment 2 Johan Euphrosine 2006-08-24 02:22:03 UTC
(In reply to comment #1)
> 4.2.0 rejects the code:
> t.cc:10: error: 'Crash' is not a member of 'T'
> 

nested.cpp:10: internal compiler error: in lookup_member, at cp/search.c:1212
on g++-4.2 version 4.2.0 20060709 (experimental) (Debian 4.2-20060709-1)

which g++-4.2 revision are you using to get ?:
t.cc:10: error: 'Crash' is not a member of 'T'
Comment 3 Andrew Pinski 2006-08-24 03:41:01 UTC
(In reply to comment #2)
> which g++-4.2 revision are you using to get ?:
4.2.0 20060821 aka two days ago's.  I bet it was also fixed by 28304.

You are using a month's old 4.2 compiler which is why you don't see the fix.  If you are going to try the mainline, please try with at a max a week old compiler.
Comment 4 Wolfgang Bangerth 2006-10-12 01:47:05 UTC
I can confirm that this is apparently fixed now.

W.