Bug 43275 - unclear error message for missing typename
Summary: unclear error message for missing typename
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.4.1
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
Depends on:
Blocks:
 
Reported: 2010-03-06 15:18 UTC by Kai Henningsen
Modified: 2011-09-28 22:45 UTC (History)
1 user (show)

See Also:
Host: x86_64-linux-gnu
Target: x86_64-linux-gnu
Build: x86_64-linux-gnu
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kai Henningsen 2010-03-06 15:18:30 UTC
This error message:

error: type 'type1' is not derived from 'type2'

is rather unclear. The first reaction is to look at the source, see that indeed, type1 is not derived from type2, and say "... and why does that matter?!"

Source:

template < typename A > struct B {
  typedef int C;
};
template < typename A > struct D {
  struct E {
    B < A >::C f;
  };
};

6: error: type 'B<A>' is not derived from type 'D<A>::E'
6: error: expected ';' before 'f'

The problem here is that there should be a 'typename' before 'B<A>::C', but the error message contains no hint of that, in addition to missing any hint of why the compiler would expect a derived type here anyway.
Comment 1 Paolo Carlini 2011-09-28 22:45:39 UTC
The error message on 4.5.x, 4.6.x and mainline seems pretty good to me:

43275.C:6:5: error: need ‘typename’ before ‘B<A>::C’ because ‘B<A>’ is a dependent scope