This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
c++/2184: using declarations for classes in function templates
- To: gcc-gnats at gcc dot gnu dot org
- Subject: c++/2184: using declarations for classes in function templates
- From: Sylvain dot Pion at sophia dot inria dot fr
- Date: Mon, 5 Mar 2001 19:23:06 +0100
- Cc: Sylvain dot Pion at sophia dot inria dot fr
>Number: 2184
>Category: c++
>Synopsis: using declarations for classes in function templates
>Confidential: no
>Severity: critical
>Priority: medium
>Responsible: unassigned
>State: open
>Class: rejects-legal
>Submitter-Id: net
>Arrival-Date: Mon Mar 05 10:26:01 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:
>Release: 3.0 20010305 (prerelease)
>Organization:
>Environment:
System: Linux zosma 2.2.14 #1 SMP Fri Jan 14 14:39:36 MET 2000 i686 unknown
Architecture: i686
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: /u/zosma/0/prisme/spion/gcc/gcc/configure --with-as=/u/zosma/0/prisme/spion/gcc/Binutils/Linux/bin/as --with-ld=/u/zosma/0/prisme/spion/gcc/Binutils/Linux/bin/ld --enable-languages=c++ --prefix=/u/zosma/0/prisme/spion/gcc/Linux_CVS_v3
>Description:
The following code doesn't compile on the 3.0 branch. It's a regression
compared to 2.95.2. It gives :
pr_vector.C: In function `void f(const J&)':
pr_vector.C:9: ISO C++ forbids declaration of `vector' with no type
pr_vector.C:9: template-id `vector<int>' used as a declarator
pr_vector.C:9: parse error before `;' token
pr_vector.C: In function `void f(const J&) [with J = int]':
pr_vector.C:13: instantiated from here
pr_vector.C:9: `typedef int vector' redeclared as different kind of symbol
pr_vector.C:3: previous declaration of `template<class T> class std::vector'
pr_vector.C:9: declaration of `typedef vector vector'
pr_vector.C:3: conflicts with previous declaration `template<class T> class
std::vector'
Note 1 : it works when f() is not template.
Note 2 : it's similar to the PR c++/1981, which was fixed by Nathan Sidwell,
but this new one concerns classes instead of functions.
>How-To-Repeat:
namespace std {
template <class T>
class vector {};
}
template <class J>
void f(const J&) {
using std::vector;
typedef vector<int> V;
}
int main() {
f(0);
}
>Fix:
I don't know of any workaround, except not using "using", and using
std::vector directly.
>Release-Note:
>Audit-Trail:
>Unformatted: