public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* optimization/6692: Tail call optimization does not work for function pointers
@ 2002-05-17  4:26 wlux
  0 siblings, 0 replies; 2+ messages in thread
From: wlux @ 2002-05-17  4:26 UTC (permalink / raw)
  To: gcc-gnats


>Number:         6692
>Category:       optimization
>Synopsis:       Tail call optimization does not work for function pointers
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          pessimizes-code
>Submitter-Id:   net
>Arrival-Date:   Fri May 17 04:26:05 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Wolfgang Lux
>Release:        gcc version 3.1
>Organization:
>Environment:
Sparc Solaris 2.8
gcc configured with: --program-suffix=-3.1 --enable-languages=c
>Description:
The tail call optimization introduced in Gnu C version 3
does not work if the tail call is made through a function
pointer, e.g.

int exec(int (*f)(int), int n)
{
    return (*f)(n);
}

The code generated for this function calls the function
passed via f recursively in a new stack frame instead of
releasing exec's stack frame and jumping to f's entry-point.
>How-To-Repeat:
Compile bug.c with -O2 and run the executable. It crashes
with a Segmentation Fault due to a stack overflow (can be
confirmed with gdb).
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="bug.c"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="bug.c"

aW50IGYxKGludCksIGYyKGludCk7CQkvKiBmdW5jdGlvbiBwcm90b3R5cGVzICovCmludCBnMShp
bnQpLCBnMihpbnQpOwppbnQgZXhlYyhpbnQgKCopKGludCksIGludCk7CgovKiBkaXJlY3QgY2Fs
bCAqLwppbnQgZjEoaW50IG4pCnsKICAgIHJldHVybiBmMihuICsgMSk7Cn0KCmludCBmMihpbnQg
bikKewogICAgcmV0dXJuIGYxKG4gKyAxKTsKfQoKLyogaW5kaXJlY3QgY2FsbHMgKi8KaW50IGcx
KGludCBuKQp7CiAgICByZXR1cm4gZXhlYyhnMiwgbiArIDEpOwp9CgppbnQgZzIoaW50IG4pCnsK
ICAgIHJldHVybiBleGVjKGcxLCBuICsgMSk7Cn0KCmludCBleGVjKGludCAoKmYpKGludCksIGlu
dCBuKQp7CiAgICByZXR1cm4gKCpmKShuKTsKfQoKCi8qIG1haW4gZnVuY3Rpb24gKi8KaW50IG1h
aW4oKQp7CiNpZmRlZiBJTkZJTklURQogICAgLyogdGhpcyBlbnRlcnMgYW4gaW5maW5pdGUgbG9v
cCAqLwogICAgZjEoMCk7CgojZWxzZQogICAgLyogdGhpcyBjYWxsIGNyYXNoZXMgd2l0aCBhIHN0
YWNrIG92ZXJmbG93ICovCiAgICBnMSgwKTsKI2VuZGlmCn0K


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

* Re: optimization/6692: Tail call optimization does not work for function pointers
@ 2003-02-19 10:18 ebotcazou
  0 siblings, 0 replies; 2+ messages in thread
From: ebotcazou @ 2003-02-19 10:18 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, nobody, wlux

Synopsis: Tail call optimization does not work for function pointers

State-Changed-From-To: open->closed
State-Changed-By: ebotcazou
State-Changed-When: Wed Feb 19 10:18:45 2003
State-Changed-Why:
    The feature has been implemented on the current mainline
    (which will likely become gcc 3.4).

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=6692


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

end of thread, other threads:[~2003-02-19 10:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-05-17  4:26 optimization/6692: Tail call optimization does not work for function pointers wlux
2003-02-19 10:18 ebotcazou

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).