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: Patch: New null_terminated attribute for C/C++


On Oct 15, 2002, Per Bothner <per@bothner.com> wrote:

> Fergus Henderson wrote:
>> If foo() is a varargs function that expects its argument list to be
>> terminated by a null pointer, and the user writes
>> 
>> foo(..., NULL);
>> then this code will do the wrong thing on some platforms, and so the
>> compiler should warn about it.

> The conclusion I got from the discussion was that there does not
> exist any such platform supported for Gcc where the wrong thing will
> happen

Unless the varargs function actually expected a pointer-to-member.
That's the difference between C and C++: there are no
pointers-to-members in C.  No matter how magic NULL is, it can't tell
whether the programmer meant a C-compatible pointer or a C++
pointer-to-member.

-- 
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]