This is the mail archive of the gcc-patches@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: [c++] warn if NULL is passed through varargs


On Wed, Oct 09, 2002 at 09:11:03PM +0200, Michael Matz wrote:
> Hi,
> 
> On 9 Oct 2002, Alexandre Oliva wrote:
> 
> > So GCC would be doing a favor to the user by recommending a type cast
> 
> Be careful with the favors you do to users.  They don't might like it ;-)
> 
> > to the intended pointer type in C, just like it currently does in C++
> > (except in the varargs case, that the patch fixes).
> >
> > Which of these arguments do you disagree with?  Or, which
> > counter-arguments can you bring into this debate?
> 
> Real world?  Which machine which is supported by gcc has a different
> representation of different pointer types (in C please).  And on which
> machine is the zero-bit pattern not the representation of (void*)0 (also
> C)?  I'm not saying they don't exist, and I know the standard permits such
> machines.  I'm just asking for a reality check.  If for 99% of users this
> would warn about a reality-non-issue I think the warning is not justified,
> sorry.  I mean, we can play die-hard standard only implementors (or at
> least pedantic warners about non-standard constructs); the question is, if
> this helps a big enough number of people, and does not distract a too big
> number, and is not just to pet our ego.

Well, for GCC execl(x, y, z, NULL); is not a problem in either C or C++
(as NULL is (void*)0 in C and __null in C++), assuming you don't
va_arg pointer-to-member. I think Alex wanted it as a portability warning,
ie. nothing in -Wall. If some compiler/OS defines NULL as 0, then it
might do the wrong thing on some arches with sizeof(int) != sizeof(void*)
which don't promote ... args to sizeof(void*) (x86-64, ia64, ...).

	Jakub


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