c++/3713: Pointers to functions or member functions are not compile-time constants

lerdsuwa@gcc.gnu.org lerdsuwa@gcc.gnu.org
Fri Aug 10 08:37:00 GMT 2001


Synopsis: Pointers to functions or member functions are not compile-time constants

State-Changed-From-To: open->closed
State-Changed-By: lerdsuwa
State-Changed-When: Fri Aug 10 08:37:51 2001
State-Changed-Why:
    Not a bug.  A::p must be defined somewhere outside the class
    A.  The following is the correct version of the code:
    
    #include <iostream>
    using namespace std;
    
    struct A
    {
            void foo()
            {
                    cout << __PRETTY_FUNCTION__ << endl;
            }
    			// This must be defined later
            static void (A::* const p)() = & A::foo;
    };
    void (A::* const A::p)();	// Definition
    
    int main()
    {
            A a;
            (a.*A::p)();
    }

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=3713&database=gcc



More information about the Gcc-bugs mailing list