Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.programming > #2262
| From | "BartC" <bc@freeuk.com> |
|---|---|
| Newsgroups | comp.programming |
| Subject | Re: goto |
| Date | 2012-09-28 23:39 +0100 |
| Organization | A noiseless patient Spider |
| Message-ID | <k4590m$dhl$1@dont-email.me> (permalink) |
| References | <04ef7083-e585-41b5-a7b2-9752597583d6@googlegroups.com> <k44jij$pv3$1@news.hs-niederrhein.de> <cec59517-7a04-469c-898e-e9451c8aae9d@googlegroups.com> |
"bob" <bob@coolfone.comze.com> wrote in message
news:cec59517-7a04-469c-898e-e9451c8aae9d@googlegroups.com...
> Well, I finally put it to the test with this C++ program.
> It does not compile, so I guess you can't do it.
>
> Doesn't work in C either.
>
> Sounds like the urban legend I heard was probably hyperbole or hogwash.
The tricky bit is making the label accessible outside it's scope. Try this
in gcc:
#include <stdio.h>
int glabel;
void fn1(int setup) {
if (setup) {
glabel=(int)&&lab1;
return;
}
puts("one");
puts("two");
lab1:
puts("three");
puts("four");
}
int main (void){
fn1(1); /* Copy the label address into the global */
goto *glabel;
}
It should print "three" then "four" after jumping into the function.
However, while my test didn't crash, I can't guarantee what yours will do!
--
Bartc
Back to comp.programming | Previous | Next — Previous in thread | Find similar | Unroll thread
goto bob <bob@coolfone.comze.com> - 2012-09-19 09:00 -0700
Re: goto diego <deepakpjose@gmail.com> - 2012-09-19 09:28 -0700
Re: goto diego <deepakpjose@gmail.com> - 2012-09-19 09:28 -0700
Re: goto bob <bob@coolfone.comze.com> - 2012-09-20 12:36 -0700
Re: goto Patricia Shanahan <pats@acm.org> - 2012-09-19 09:35 -0700
Re: goto "BartC" <bc@freeuk.com> - 2012-09-19 19:25 +0100
Re: goto Anonymous <nobody@remailer.paranoici.org> - 2012-09-20 17:04 +0000
Re: goto Robin Vowels <robin.vowels@gmail.com> - 2012-09-20 18:37 -0700
Re: goto Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-09-21 10:35 -0700
Re: goto Mok-Kong Shen <mok-kong.shen@t-online.de> - 2012-09-22 22:48 +0200
Re: goto Mok-Kong Shen <mok-kong.shen@t-online.de> - 2012-09-22 23:14 +0200
Re: goto Patricia Shanahan <pats@acm.org> - 2012-09-22 16:12 -0700
Re: goto Mok-Kong Shen <mok-kong.shen@t-online.de> - 2012-09-23 15:25 +0200
Re: goto Robin Vowels <robin.vowels@gmail.com> - 2012-09-28 18:07 -0700
Re: goto Florian Scholz <florian.scholz@stud.hn.de> - 2012-09-28 18:36 +0200
Re: goto bob <bob@coolfone.comze.com> - 2012-09-28 15:05 -0700
Re: goto "BartC" <bc@freeuk.com> - 2012-09-28 23:39 +0100
csiph-web