This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/21980] New: syntax error with static function pointer (compiler dependent)
- From: "nkoch at demig dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 9 Jun 2005 12:24:45 -0000
- Subject: [Bug c++/21980] New: syntax error with static function pointer (compiler dependent)
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Take this c++ code:
---- snip ----
class Test
{
private:
int val;
static Test func1 ();
static Test func2 ();
static Test (* funcp) ();
public:
Test (int val)
: val (val)
{
}
Test func ()
{
return funcp ();
}
int get () const
{
return val;
}
};
Test (* Test::funcp) () = Test::func1;
Test Test::func1 ()
{
funcp = func2;
return Test (1);
}
Test Test::func2 ()
{
return Test (2);
}
---- snip ----
The code above compiles w/o errors under 3.4.5 and produces these
errors under 3.3.6:
bug33.cpp:7: error: parse error before `*' token
bug33.cpp: In member function `Test Test::func()':
bug33.cpp:17: error: `funcp' undeclared (first use this function)
bug33.cpp:17: error: (Each undeclared identifier is reported only once for each
function it appears in.)
bug33.cpp: At global scope:
bug33.cpp:26: error: `Test (*Test::funcp)()' is not a static member of `class
Test'
Which of the compilers is right? Are static function pointers to
static class functions legal c++ code? Is the declaration syntax
standard conforming?
--
Summary: syntax error with static function pointer (compiler
dependent)
Product: gcc
Version: 3.3.6
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: nkoch at demig dot de
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i386-portbld-freebsd4.11
GCC host triplet: i386-portbld-freebsd4.11
GCC target triplet: i386-portbld-freebsd4.11
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21980