This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
c++ bug 57
- From: Nathan Sidwell <nathan at codesourcery dot com>
- To: gcc-bugs at gcc dot gnu dot org
- Cc: sebor at roguewave dot com, jason at redhat dot com, mark at codesourcery dot com
- Date: Wed, 21 Nov 2001 10:22:52 +0000
- Subject: c++ bug 57
- Organization: Codesourcery LLC
[Get raw message]
Hi,
this concerns bug report 57 where we reject the following at the
default argument
template <class T, class U>
struct {
static const int n = 0;
};
template <class T>
struct B
{
template <class U>
void foo (int = A<T, U>::n) { }
};
the difficulty is that default args have to be parsed after the class
is defined (much like inline function bodies). So we gobble them up by
looking for the next non-nested ',' or ')'. In general we can't
know whether a '<' starts a template parm list or not, so we use '()[]{}'
for nesting. In this case we could lookup A, but in general it is not.
I.e, what about
struct B {
void foo (int = A<T,U>::n);
template <class T, class U> struct A { static const int n;};
};
Is this supposed to be legal or not? Mark, Jason & I discussed this
wrt the cp-parser branch, and the conclusion was such uses were ill-formed.
This looks to be like a defect, as I can't tell from the std what is
intended. There's another related problem to do with mutual recursion within
default arguments. The legality of that is also unspecified.
struct C {
static int Foo (int = Baz ());
static int Baz (int = Foo ());
};
Does anyone have an opinion about whether or not these are legal and/or
defects?
nathan
--
Dr Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
'But that's a lie.' - 'Yes it is. What's your point?'
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org