This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/23385] New: gcc accepts "class typedefname" when typedefname is defined in a nested class and references a template parameter
- From: "fn_x at hotmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 14 Aug 2005 09:49:41 -0000
- Subject: [Bug c++/23385] New: gcc accepts "class typedefname" when typedefname is defined in a nested class and references a template parameter
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Hello,
All versions of gcc I tried (2.95.3, 3.3.6, 3.4.4, 4.0-20050811, and
4.1-20050813) accept this code without any warnings or errors (using -ansi
-pedantic -Wall -W, just in case)
template<typename T>
class A {
struct helper { typedef T type; };
friend class helper::type;
};
class B { A<B> m; } b;
int main() {}
I don't believe this code is valid. icc 9.0.021 rejects this code with
error: typedef "type" may not be used in an elaborated type specifier
and gcc 4.0-20050811 rejects it when I try the same thing with A<T>::type,
rather than A<T>::helper::type, with
error: using template type parameter ?T? after ?class?
Additionally, any attempts at using "class A<B>::helper::type" outside of the
template definition result in
error: using typedef-name ?A<B>::helper::type? after ?class?
So I think my code should result in either of the above two errors as well.
I can't find any other reports of this, but sorry if I missed anything.
--
Summary: gcc accepts "class typedefname" when typedefname is
defined in a nested class and references a template
parameter
Product: gcc
Version: 4.0.2
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: fn_x at hotmail dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23385