This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Warning for unadorned 0 in varargs lists?
On Thu, Aug 19, 2004 at 05:12:06PM -0700, Eddie Kohler wrote:
> >> This would generate the minimum number of false positives, but
> >> wouldn't
> >> catch a bunch of errors, or errors on most user functions. I'd be
> >> happy even with a version of the warning that required me to write
> >> "(int) 0" when I meant the integer zero (in varargs lists only).
> >
> > But if the attribute approach were followed, the user can add her own
> > attributes to do checking for execl-like functions. This is already
> > easily done for nonstandard printf-like functions.
>
> Yes, the attribute approach is better. But the particular function
> that's giving me problems has a "type" like
> int (*)(void*, int, int, [const char*, int]*, const char* = 0)
> so it's not execl-like.
But if there is such a prototype in scope, then a literal 0 argument will
be cast to a const char*, even on a platform with 32-bit int and 64-bit
pointers. So what is the problem? Does your code omit the prototype
altogether and hope that the right thing happens?