This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
c++/9252: [3.4 regression][New parser] Errors due to legally used "typename"
- From: bangerth at ticam dot utexas dot edu
- To: gcc-gnats at gcc dot gnu dot org
- Date: 9 Jan 2003 19:14:22 -0000
- Subject: c++/9252: [3.4 regression][New parser] Errors due to legally used "typename"
- Reply-to: bangerth at ticam dot utexas dot edu
>Number: 9252
>Category: c++
>Synopsis: [3.4 regression][New parser] Errors due to legally used "typename"
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Jan 09 11:16:01 PST 2003
>Closed-Date:
>Last-Modified:
>Originator: Wolfgang Bangerth
>Release: unknown-1.0
>Organization:
>Environment:
3.4 since new parser merge
>Description:
This code
---------------------------
class O {
struct I { I (int); };
template <class T_>
friend typename O::I f ();
};
template <class T_>
typename O::I f () { return 1; };
struct X {
void g() { f<int>(); }
};
----------------------------------
used to compile until 3.3, but with the new parser I get
tmp/g> /home/bangerth/bin/gcc-3.4-pre/bin/gcc -c x.cc
x.cc:2: error: `struct O::I' is private
x.cc:9: error: within this context
x.cc:2: error: `struct O::I' is private
x.cc:9: error: within this context
The message is clearly wrong, and furthermore goes away
if the "typename" is removed in the two places where it is
not necessary! Weird, and not very helpful to find the
real cause of the problem.
On the other hand, Gaby pointed out the right place in the
standard that seems to indicate the validity of the use
of "typename" here:
| > 14.6/5:
| >
| > The keyword typename shall only be used in template declarations and
| > definitions, including in the return type of a function template or
| > member function template, in the return type for the definition of a
| > member function of a class template or of a class nested within a
| > class template, and in the type-specifier for the def-inition of a
| > static member of a class template or of a class nested within a
| > class template. The keyword typename shall only be applied to
| > qualified names, but *those names need not be dependent*. [...]
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted: