public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c++/3713: Pointers to functions or member functions are not compile-time constants
@ 2001-07-17 10:16 philippeb
  0 siblings, 0 replies; 3+ messages in thread
From: philippeb @ 2001-07-17 10:16 UTC (permalink / raw)
  To: gcc-gnats

>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==


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: c++/3713: Pointers to functions or member functions are not compile-time constants
@ 2001-09-17  7:22 lerdsuwa
  0 siblings, 0 replies; 3+ messages in thread
From: lerdsuwa @ 2001-09-17  7:22 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, nobody, philippeb

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

State-Changed-From-To: closed->open
State-Changed-By: lerdsuwa
State-Changed-When: Mon Sep 17 07:22:53 2001
State-Changed-Why:
    Test case reopened.  After the fix, and compile with
    optimization, function is still not inlined.  Dump of
    assembly in followup shown in PR4277.

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: c++/3713: Pointers to functions or member functions are not compile-time constants
@ 2001-08-10  8:37 lerdsuwa
  0 siblings, 0 replies; 3+ messages in thread
From: lerdsuwa @ 2001-08-10  8:37 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, nobody, philippeb

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2001-09-17  7:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-07-17 10:16 c++/3713: Pointers to functions or member functions are not compile-time constants philippeb
2001-08-10  8:37 lerdsuwa
2001-09-17  7:22 lerdsuwa

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).