This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: PR c++/11987: why is it invalid?
Mark Mitchell <mark@codesourcery.com> writes:
> Ian Lance Taylor wrote:
>
> > ==================================================
> > template <int dim> struct X {
> > struct I { I(); void foo(); };
> > };
> >
> > template <int dim> struct Y : X<dim> {
> > typedef typename X<dim>::I I;
> > };
> >
> > template <int dim>
> > void Y<dim>::I::foo () {}
> >
> > template struct Y<1>;
> > ==================================================
>
> This should be invalid too, assuming I'm remembering correctly. I think
> you have to say X<dim>::I::foo() when you make the definition.
(First of all, let me to say that I don't want to pick on Mark here,
he's just the one answering.)
OK, here is gcc/testsuite/g++.dg/eh/spec4.C:
==================================================
// PR c++/5104
// Test that a function with a throw spec is a valid template argument.
#include <exception>
typedef void (*HandlerFunction)();
typedef HandlerFunction (*SetHandlerFunction)(HandlerFunction);
template <SetHandlerFunction set_function>
class HandlerStack {
public:
static void defaultHandler();
};
typedef HandlerStack<std::set_terminate> Terminate;
template<> void Terminate::defaultHandler() {}
==================================================
This test case uses a typedef when defining the function
defaultHandler. Is this code legal? If yes, then what is the
difference between this and the example above?
A similar yet different case appears in g++.dg/parse/ctor2.C:
==================================================
// PR c++/19244
typedef struct { void f(); } f;
void f::f() { }
==================================================
(These are, of course, cases I found with one version of my attempt to
patch this PR.)
Ian