c++ bug 57

Martin Sebor sebor@roguewave.com
Mon Nov 12 08:06:00 GMT 2001


Mark Mitchell wrote:
> 
> --On Wednesday, November 21, 2001 10:22:52 AM +0000 Nathan Sidwell
> <nathan@codesourcery.com> wrote:
> 
>         struct B {
>                 void foo (int = A<T,U>::n);
>                 template <class T, class U> struct A { static const int n;};
>         };
> 
> This should be invalid.  The standard should say specifically that the
> default argument expression is taken to be the next sequence of tokens
> up to an unnested `,', where nested means nested within parentheses,
> braces, or square brackets.

I'm not sure I'm quite following this discussion. The above snippet
is, IMHO, clearly ill-formed for at least two reasons:

    1. T and U are not defined at the point of declaration of foo.
    2. A is not in scope at the point of declaration of foo.

This is ill-formed only due to (2):

    template <class V, class W>
    struct B {
        void foo (int = A<V, W>::n);
        template <class T, class U> struct A { static const int n;};
    };

But this is well-formed:

    template <class V, class W>
    struct B {
        template <class T, class U> struct A { static const int n;};
        void foo (int = A<V, W>::n);
    };


Regards
Martin



More information about the Gcc-bugs mailing list