prev up next top/contents search

comp.lang.c FAQ list · Question 2.18

Q: This program works correctly, but it dumps core after it finishes. Why?

	struct list {
		char *item;
		struct list *next;
	}
	/* Here is the main program. */
	main(argc, argv)
	{ ... }


A: A missing semicolon at the end of the structure declaration causes main to be declared as returning a structure. (The connection is hard to see because of the intervening comment.) Since structure-valued functions are usually implemented by adding a hidden return pointer (see question 2.9), the generated code for main() tries to accept three arguments, although only two are passed (in this case, by the C start-up code). See also questions 10.9 and 16.4.

References: CT&P Sec. 2.3 pp. 21-2


prev up next contents search
about this FAQ list about eskimo search feedback copyright

Hosted by Eskimo North

AltStyle によって変換されたページ (->オリジナル) /