Path: utzoo!dptcdc!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!leah!rds95 From: rds95@leah.Albany.Edu (Robert Seals) Newsgroups: comp.lang.c Subject: Address of a goto label? Keywords: hmmm Message-ID: <1768@leah.Albany.Edu> Date: 18 Apr 89 17:39:00 GMT Organization: The University at Albany, Computer Services Center Lines: 48 Hi again, A quote from Ken Arnold's April 1989 "C Advisor" column in Unix Review: ...you can take the address of a goto label and start stuffing data into it. Well, the whole article was tongue-in-chic, and in fact included a reference that said, ...write a column which _looked_ normal, but actually contained some harmless misinformation... So, the idea of taking the address of a goto label seemed thrilling, and I wrote a program to test it. Thus, #include main() { int *p; HERE: p = &HERE; printf("%d\n", p); } But it don't verk; at least, the FIRST system I tested it on didn't verk. The error was "undefined symbol" when taking the address of HERE. So, I checked K&R2, which says: The only use of an identifier label is as a target of goto. So, the failed compilation seemed correct. BUT, I tried it on the local 4.3-tahoe, and it compiled, and gave a warning about taking the address of an array or function, and the & would be ignored, and it ran and the program printed "76\n" (unoptimized). So I tried it on good old Ultrix 1.2 cc, and got the same as 4.3, except that I got 80 instead of 76. And then gcc said "undeclared variable." So I guess that this is an ANSI thingy-doo, and the answer I will get is, "it's grotesque, but it works on old compilers" to the question (what is this, Jeopardy?) "what is the deal here, anyway?" rob