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 Oct 11, 2002, Jason Merrill <jason@redhat.com> wrote:

> On 09 Oct 2002 16:57:37 -0300, Alexandre Oliva <aoliva@redhat.com> wrote:
>> The problem in C++ is very real.  __null doesn't decay to a
>> pointer-wide integer type in varargs, and this has caused a run-time
>> error in an application, which got me into writing this patch.

> Please elaborate.  It's certainly intended to decay to a pointer-wide
> integer.

I see its type is a POINTER_SIZE integer type, but that's not the only
kind of pointer in C++.  NULL also stands for a NULL pointer-to-member
constant, and that's wider.  It's this ambiguity that we should warn
about.

That said, all I know about the problem was that gnomemeeting, being
compiled to a 64-bit target, passed NULL as the last argument to a
varargs function, and it crashed, but adding a cast to (glong) fixed
it.  I'll try to find out which target it was, which exact version of
gcc was being used, and whether g++'s definition of NULL was in
effect.

-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                 aoliva@{redhat.com, gcc.gnu.org}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist                Professional serial bug killer


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