This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [c++] warn if NULL is passed through varargs
>>>>> "Daniel" == Daniel Jacobowitz <drow@mvista.com> writes:
Daniel> On Wed, Oct 09, 2002 at 01:24:34PM +1000, Fergus Henderson
Daniel> wrote:
>> On 08-Oct-2002, Andrew Pinski <pinskia@physics.uc.edu> wrote: > I
>> think you need a test for this if you are going to > add it to
>> show it works and will work for the future > so we do not have
>> another feature that dies out like > `typedef X=0;'. Also does
>> this is a good idea for > the c front end too even though c
>> requires NULL to > be a pointer type?
>>
>> C does not require NULL to have a pointer type. C requires NULL
>> to be a null pointer constant, but that doesn't mean it has a
>> pointer type; for example, `0' is a valid null pointer constant,
>> and `0' has type `int', not a pointer type. If you pass it
>> through `...' then there is no guarantee that it will have the
>> same representation as a null pointer.
>>
>> So yes, this warning is a good idea for the C front end too.
Daniel> You've got to be kidding.
Daniel> - First of all, there's no real way to figure it out. C++
Daniel> has __null (spelling?), but C just has a NULL somewhere.
Daniel> Defined usually as (void*) 0, at least for GCC.
I had the same reaction. In C, NULL is just a #define, whose
definition varies. I haven't actually done a census -- my own
favorite definition is simply 0 -- without any pointer casts that are
after all unnecessary.
paul