This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
c++/10261: g++ does not error for bogus |typename| inside a templated class
- From: bbaetz at acm dot org
- To: gcc-gnats at gcc dot gnu dot org
- Date: Sat, 29 Mar 2003 12:55:46 +1100
- Subject: c++/10261: g++ does not error for bogus |typename| inside a templated class
>Number: 10261
>Category: c++
>Synopsis: g++ does not error for bogus |typename| inside a templated class
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: unassigned
>State: open
>Class: accepts-illegal
>Submitter-Id: net
>Arrival-Date: Sat Mar 29 01:56:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator: Bradley Baetz
>Release: 3.4 20030328 (experimental)
>Organization:
>Environment:
System: Linux mango.home 2.4.18-27.8.0custom #1 Thu Mar 20 20:14:56 EST 2003 i686 i686 i386 GNU/Linux
Architecture: i686
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ../gcc/configure --enable-languages=c,c++ --prefix=/home/bbaetz/swtest --program-suffix=-cvs --enable-__cxa_atexit
>Description:
g++ (3.2 and 3.4-cvs) accepts the use of the |typename| keyword even when
the template is explicitly instatiated and does not have dependant
parameters, if the use of this occurs from within a template (see example
below)
I'm not sure that this is a bug. I only have access to the draft c++
standard, but foo<int>::value_type doesn't depend on T, and the |baz| code
is accepted without the typename also, even in 3.4.
MIPSPro 7.4 appears to disallow both cases, too - see
http://bugzilla.mozilla.org/show_bug.cgi?id=199625 (It also disallows
|typename| as a function param in a templated class, which I think is
incorrect although I'm not sure, so maybe its results should be taken with
a grain of salt...)
However, this appears to be handled by core issue 183
(http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/cwg_defects.html#183) though,
which does make the use of |typename| illegal.
>How-To-Repeat:
template<typename T>
struct foo {
typedef T value_type;
};
struct bar {
typedef typename foo<int>::value_type t; //errors
void xxx(typename foo<int>::value_type); //errors
};
template<typename T>
struct baz {
typedef typename foo<int>::value_type t; //ok, but should be error
void yyy(typename foo<int>::value_type); //ok, but should be error
};
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted: