From: Steven Jenkins Date: 2005-02-24T03:14:21+09:00 Subject: Re: Strange argc check in stable snapshot Berger, Daniel wrote: >>-----Original Message----- >>From: Steven Jenkins [mailto:steven.jenkins@ieee.org] >>Maybe a good idea nonetheless. It might catch a bug someday. Nothing >>*guarantees* that argc is nonnegative, not even for main(). > > I'll pledge $100 to RubyCentral immediately if someone can actually > demonstrate how this might occur. > > And no, assigning a negative value to argc directly doesn't count. :-P int main(int argc, char *argv[]) { if (argc < 0) return 0; else main(-1, 0); } This is perfectly legal C. There's nothing special about main() except that the loader uses it as the entry point. Any other function can call it, including itself. The argc in question is nonnegative by convention only. Someone could just make a mistake and call it with the wrong argument. Steve