Article View: comp.std.c
Article #4122Re: Nested functions (was: Re: GOTO single exit point)
From: Olaf Weber
Date: Tue, 26 Sep 1995 14:34
Date: Tue, 26 Sep 1995 14:34
25 lines
1701 bytes
1701 bytes
In article <448uaq$28g@rdsunx.crd.ge.com>, Christopher R. Volpe writes: > Ok, I'll bite: What happens if the nested function references auto > variables in the enclosing function, and then the nested function is > called through a function pointer when the enclosing function is not > active and said auto variable doesn't exist? In general, one of two things happens: either the compiler generated code that can check for this, and crash the program gracefully, or the program yields undefined behaviour (i.e., crashes gracelessly). This is more or less independent of whether you use trampolines or "fat" function pointers. Checking for the possible appearance of this condition can partly be done statically, if assignment of function pointers were governed by rules similar to those of ALGOL 68. Even so, runtime checks are needed to cover all cases, and I suspect that these are easier to implement when fat function pointers are used. But note that C suffers from exactly this problem already, because a function can export pointers to automatic variables, which can be kept even after the function has exited. -- Olaf Weber
Technical Details
Message-ID:
<DFIoI6.26I@cwi.nl>Path:
arc1-ca.pugleaf.net!cwi.nl!newsReferences:
<dqua.811915828@dqua> <1995Sep25.114935.1575@ittpub> <446ttn$deg@news0.rain.rg.net> <448uaq$28g@rdsunx.crd.ge.com>Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c Path: arc1-ca.pugleaf.net!cwi.nl!news From: Olaf Weber <Olaf.Weber@cwi.nl> Subject: Re: Nested functions (was: Re: GOTO single exit point) In-Reply-To: volpe@bart.crd.ge.com's message of 26 Sep 1995 13:14:02 GMT Message-ID: <DFIoI6.26I@cwi.nl> Sender: olaf@havik.cwi.nl Nntp-Posting-Host: havik.cwi.nl Organization: CWI, Amsterdam X-Newsreader: Gnus v5.0 References: <dqua.811915828@dqua> <1995Sep25.114935.1575@ittpub> <446ttn$deg@news0.rain.rg.net> <448uaq$28g@rdsunx.crd.ge.com> Date: Tue, 26 Sep 1995 14:34:52 GMT