This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Warning for unadorned 0 in varargs lists?


On Mon, 23 Aug 2004, Kaveh R. Ghazi wrote:

> I'd like to propose the following design:
> 
> __attribute__ ((sentinel [, sentinel_position_from_end [, sentinel_value]]))

I'd suggest a refinement: that the variadic arguments before the sentinel 
should be required to have types interchangable with the type of the 
sentinel in va_arg.  So for a sentinel of type void * they could have 
types pointer to void or to character types, or any pointer type unless 
-pedantic (as with format warnings for printf %p).

(Such a requirement can't be applied to arguments after the sentinel; 
there's no particular reason for them to have types interchangable with 
it, and execle doesn't.)

In addition, the sentinel is the first variadic argument with the right 
value, and subsequent arguments beyond sentinel_position_from_end of them 
would be warned for unless -Wno-format-extra-args.

-- 
Joseph S. Myers               http://www.srcf.ucam.org/~jsm28/gcc/
    jsm@polyomino.org.uk (personal mail)
    jsm28@gcc.gnu.org (Bugzilla assignments and CCs)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]