This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
Re: c++/9298: [3.4 regression] [new parser] ICE with function-pointer-type template args
- From: Volker Reichelt <reichelt at igpm dot rwth-aachen dot de>
- To: nobody at gcc dot gnu dot org
- Cc: gcc-prs at gcc dot gnu dot org,
- Date: 15 Jan 2003 20:46:02 -0000
- Subject: Re: c++/9298: [3.4 regression] [new parser] ICE with function-pointer-type template args
- Reply-to: Volker Reichelt <reichelt at igpm dot rwth-aachen dot de>
The following reply was made to PR c++/9298; it has been noted by GNATS.
From: Volker Reichelt <reichelt@igpm.rwth-aachen.de>
To: bangerth@ticam.utexas.edu
Cc: gcc-bugs@gcc.gnu.org, gcc-gnats@gcc.gnu.org
Subject: Re: c++/9298: [3.4 regression] [new parser] ICE with function-pointer-type template args
Date: Wed, 15 Jan 2003 22:39:56 +0100
Hi Wolfgang,
sorry for the confusion, I was *quite* wrong.
Let's have another look at the code:
The declaration of foo as a static template function is of course legal.
But I disagree with you when you say
> It's illegal, though, to use its address as a template parameter!
Why should it be illegal? You can use the address of a static variable as
a template parameter, too:
------------snip here-------------
int i;
template <int*> void foo() {}
template void foo<&i> ();
----------------------------------
You're right, there's only one bug in the following line:
> template int CPU::dispatch<&template foo<2> > ();
^^^^^^^^
And then, there's one more bug in the whole file:
We only have declarations for "foo" and "dispatch", but we need
definitions for the explicit instantiation of dispatch and its
template parameter.
Given that, the following code should compile IMHO (the EDG front-end
thinks so, too):
----------------------snip here-------------------
struct A
{
typedef void (*pfun)();
template <pfun> static void bar() {}
};
template <int> static void foo() {}
template void A::bar< &foo<0> >();
----------------------snip here-------------------
Alas, each gcc version since 2.95.x rejects the code with a message similar to
bug.cc:10: `&foo<0>' is not a valid template argument
bug.cc:10: template-id `bar<(&foo<0>)>' for `void A::bar()' does not match any
template declaration
(That's probably why I ended up changing random things in the code to make
it compile and came up with the bogus errors from my first message.)
That leaves us with an additional rejects-legal bug.
I'll open an additional PR for that one, if you agree.
Regards,
Volker