This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/17359] New: Can't convert function pointer
- From: "bangerth at dealii dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 8 Sep 2004 21:03:46 -0000
- Subject: [Bug c++/17359] New: Can't convert function pointer
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
[Taken from http://gcc.gnu.org/ml/gcc/2004-09/msg00389.html]
We can't compile this:
----------------------
class B {};
struct D : public B {
template <int> void foo();
};
typedef void (B::*BfooPtr)();
typedef void (D::*fooPtr)();
void bar () {
static_cast<BfooPtr>(&D::foo<1>);
static_cast<BfooPtr>((fooPtr)&D::foo<1>);
}
----------------------------
g/x> /home/bangerth/bin/gcc-3.5-pre/bin/c++ -c x.cc
x.cc: In function `void bar()':
x.cc:11: error: invalid static_cast from type `<unknown type>' to type `void
(B::*)()'
Note that the first line with the static_cast fails, whereas the second one
succeeds. This is wrong, since the cast in the second line only casts the
member function pointer to exactly its type as before.
gcc is also wrong, since the same code succeeds when foo() is not a template,
and finally the error message with <unknown type> is really unhelpful: after
all we completely resolved the overload set to a single function by
specifying the template argument.
W.
--
Summary: Can't convert function pointer
Product: gcc
Version: 3.5.0
Status: UNCONFIRMED
Keywords: rejects-valid
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: bangerth at dealii dot org
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17359