[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug c++/14534] Unrecognizing static function as a template parameter wh
From: |
bangerth at dealii dot org |
Subject: |
[Bug c++/14534] Unrecognizing static function as a template parameter when its return value is also templated |
Date: |
11 Mar 2004 16:05:38 -0000 |
------- Additional Comments From bangerth at dealii dot org 2004-03-11 16:05
-------
Confirmed indeed. This never worked, and still doesn't.
One rather confusing thing: for this code snippet
-------------
template <int (*)()> class Far {};
struct Boo {
static int some();
typedef Far<some> far_type;
};
-------------
we get
g/x> /home/bangerth/bin/gcc-3.5-pre/bin/c++ -c x.cc
x.cc:4: error: `static int Boo::some()' cannot appear in a constant-expression
x.cc:4: error: template argument 1 is invalid
x.cc:4: error: ISO C++ forbids declaration of `far_type' with no type
(which I find particularly confusing because the error message refers to
Boo::some -- which I didn't write this way, and as the submitter correctly
noticed: had I written it in this way, the compiler had accepted it.
However, it gets worse: if I don't use the automatic decay to a function
pointer and write the address-of explicitly, i.e.
------------------
template <int (*)()> class Far {};
struct Boo {
static int some();
typedef Far<&some> far_type;
};
------------------
then the error message changes to the even more unreadable
g/x> /home/bangerth/bin/gcc-3.5-pre/bin/c++ -c x.cc
x.cc:4: error: missing `>' to terminate the template argument list
x.cc:4: error: template argument 1 is invalid
x.cc:4: error: ISO C++ forbids declaration of `some' with no type
x.cc:4: error: expected `;' before '>' token
Which is totally bogus.
W.
--
What |Removed |Added
----------------------------------------------------------------------------
Known to fail|3.5.0 |2.95.3 3.2.3 3.3.3 3.4.0
| |3.5.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14534