Warning for unadorned 0 in varargs lists?

Kaveh R. Ghazi ghazi@caip.rutgers.edu
Mon Aug 23 16:39:00 GMT 2004


 > It's not a problem for it to accept a NULL env pointer, that's still
 > exactly one argument after the sentinel.  The point being that if you
 > have two arguments after the sentinel (say), only the first would be
 > considered and the subsequent ones would be ignored.  Likewise, with
 > execl, any arguments after the sentinel are ignored.

Hmm, I'm not sure I understand all the nuances here.  Suppose we had a
function prototype:

	void foo (char *, ...) __attribute__ ((__sentinel__, 1));

and a function call:

	foo ("blah", "blah", NULL, NULL, NULL);
	foo ("blah", "blah", NULL, NULL, "blah");

you're saying that the above should get a warning for extra sentinel
arguments and/or extra arguments after the supposed end position, but:

	foo ("blah", "blah", "blah", NULL, NULL);
	foo (NULL, "blah", "blah", NULL, NULL);

would be okay.  Right?  If so I agree that your refined check is
useful.  I would still suggest that the robustness of the checking be
left as a followup refinement not a requirement for initial patch
acceptance.  I don't want to discourage any one from working on it
because the job is bigger than the itch they want to scratch.


Also regardless of the nuances of the checking, the syntax I outlined
is unaffected.  So far I haven't heard any problems with it (crossing
my fingers.)

		--Kaveh
--
Kaveh R. Ghazi			ghazi@caip.rutgers.edu



More information about the Gcc mailing list