Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site puff.UUCP Path: utzoo!watmath!clyde!bonnie!akgua!gatech!seismo!uwvax!puff!tom From: tom@puff.UUCP Newsgroups: net.lang.c Subject: mildly obfuscating c Message-ID: <564@puff.UUCP> Date: Fri, 6-Dec-85 17:54:16 EST Article-I.D.: puff.564 Posted: Fri Dec 6 17:54:16 1985 Date-Received: Sun, 8-Dec-85 03:23:54 EST Distribution: net Organization: U of Wisconsin CS Dept Lines: 81 ok, guys, now i will admit that the below code is *not* kosher. but the question still remains, if you run this program, what will your output be? does the machine you compile it on make a difference? does defining ARG to be something, say 999, make a difference? what if VAR were auto or static? ------------------------------------------------------------- # define ARG # define VAR register # define CALL(x) (*(int (*)()) (x))(ARG) main() { VAR thing = 0; stuff: printf("here it goes, thing is %d\n",thing); if (!thing++) CALL(stuff); printf("one there it went, thing is %d\n",thing); printf("two there it went, thing is still %d\n",thing); } /* lint outputs test.c: test.c(8): warning: questionable conversion of function pointer */ ------------------------------------------------------------- note the lint output. no kidding. on a vax, i get a reserved intruction trap as soon as i call the label. on a gould, the program runs normally, but i get this: ------------------------------------------------------------- here it goes, thing is 0 here it goes, thing is 1 here it goes, thing is 1 two there it went, thing is still 2 ------------------------------------------------------------- which is quite interesting. the third line has the wrong string on the stack at the time. on a pyramid, this is the bizarre result: ------------------------------------------------------------- here it goes, thing is 0 here it goes, thing is 536151860 one there it went, thing is 536151861 two there it went, thing is still 536151861 one there it went, thing is 1 two there it went, thing is still 1 ------------------------------------------------------------- i haven't been able to figure out anyway to "goto" a label that i don't know. for example, i would like to do this: ------------------------------------------------------------- main() { int (*jump[])() = { l1,l2,l3,l4,l5,l6,l7,l8 } l1: /* code */ l2: /* code */ l3: /* code */ l4: /* code */ l5: /* code */ l6: /* code */ l7: /* code */ l8: /* code */ goto *jump[whatever] } ------------------------------------------------------------- aside from the forward-referencing problem of the unseen labels, this is a still syntax error. anyone have any way to do this? tom