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

philippeb@videotron.ca philippeb@videotron.ca
Tue Jul 17 10:16:00 GMT 2001


>Number:         3713
>Category:       c++
>Synopsis:       Pointers to functions or member functions are not compile-time constants
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Jul 17 10:16:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     g++ 2.95.4
>Release:        20010319 (Debian prerelease)
>Organization:
>Environment:
Debian Linux on i386
>Description:
Pointers to functions or member functions are not compile-time constants, meaning that the functions won't be inlined, even if the function is not virtual. It seems also that 'const' modifiers applied to pointers to member are discarded (tested by calling a template function).

The attached program demontrates the problem by confirming that the compiler needs references to those constants:

/tmp/ccQihCjs.o: In function `main':
/home/philippeb/devel/tests/inlineptf.cpp:17: undefined reference to `A::p'
/home/philippeb/devel/tests/inlineptf.cpp:17: undefined reference to `A::p'
>How-To-Repeat:

>Fix:
Don't use a pointer to function if you want your code to be inlined.
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/x-c++src; name="inlineptf.cpp"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="inlineptf.cpp"

I2luY2x1ZGUgPGlvc3RyZWFtPgoKCnN0cnVjdCBBCnsKCXZvaWQgZm9vKCkKCXsKCQljb3V0IDw8
IF9fUFJFVFRZX0ZVTkNUSU9OX18gPDwgZW5kbDsKCX0KCglzdGF0aWMgdm9pZCAoQTo6KiBjb25z
dCBwKSgpID0gJiBBOjpmb287Cn07CgppbnQgbWFpbigpCnsKCUEgYTsKCShhLipBOjpwKSgpOwp9
Cg==



More information about the Gcc-bugs mailing list