Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!cbosgd!ihnp4!ptsfa!ames!hc!beta!cmcl2!rutgers!bellcore!faline!ulysses!allegra!alice!ark From: ark@alice.UUCP Newsgroups: comp.lang.c Subject: Re: IBM RT compiler weirdness Message-ID: <7247@alice.UUCP> Date: Sat, 29-Aug-87 10:50:15 EDT Article-I.D.: alice.7247 Posted: Sat Aug 29 10:50:15 1987 Date-Received: Wed, 2-Sep-87 02:08:51 EDT References: <261@calyx.UUCP> Organization: AT&T Bell Laboratories, Liberty Corner NJ Lines: 36 In article <261@calyx.UUCP>, usenet@calyx.UUCP writes: > Keywords:missing semicolons, lint, silent! > #include > > struct junk { > int a; > int b; > } > > main(argc,argv) > int argc; > char **argv; > { [ program body deleted ] > It compiled fine. Lint said nothing. But the output was garbage: it seems > that the missing semi-colon after the struct definition caused argc > to be given the value of argv, and argv got the value of the environment > varible pointer. No, the missing semi-colon after the struct definition said that your program returns a "struct junk". From your description, it appears that your compiler handles structure returns by passing an extra argument to the function in question, presumably to hold the address of memory in which to place the returned structure. This is a legitimate way of doing it -- and in fact has some advantages over the way most C compilers seem to work -- but does have the disadvantage that some invalid programs which work by coincidence on most implementations will blow up on this one. In particular, a function which returns a different type from the type declared for it will result in just about the kind of problem you've described. Since main() is supposed to return an int, and you've made it return a struct, you're out of luck.