Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!usc!apple!voder!pyramid!cbmvax!amix!usblues!tom From: tom@usblues.UUCP (Tom Markson) Newsgroups: comp.lang.c Subject: Is goto safe? Keywords: C Message-ID: <253@usblues.UUCP> Date: 17 Jan 90 09:45:35 GMT Organization: Oyster Bay Software, Pittsburgh, PA Lines: 39 I posted this previously, but I don't think it went out. Apologies if it did. Without getting into style issues, is the goto statement in C safe? For instance, If I do the following, am I guarenteed that no stack crashes will occur: main() { { int i; i=0; inside: i++; printf("inside:%d\n",i); goto outside; } { int j; j=0; outside: j++; printf("outside: %d\n",j); goto inside; } } My C compiler (xenix) codes this and it runs. i and j keep their values. The .s file indicates that all stack space is allocated at the start of a function. Question: Is this always true. Will it always run as expected with i and j incrementing from 0 to ...? Note: According to K & R, the one restriction to goto is that it must be within a func. Can I count on this being the only restriction? Thank you in advance. -- Tom Markson ...!uunet!usblues!tom ...!cbmvax!amix!blekko!usblues!tom