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


> But I'm not even sure this
> alone is allowed to break passing NULL through varargs, _even_ if we have
> different pointers, because all null pointers of all types are required to
> compare equal, and furthermore can be converted to null pointers (and only
> to null pointers) of other types.

Yes, but it's the compiler's job to make sure this C requirement holds.
And the compiler can't do it in the case of passing NULL through varargs,
as it doesn't know the pointer's type.

See also the C FAQ, section 5.2

> Can someone come up with a non-conforming C program (with recognizable
> effects breaking the as-if rule) using NULL in varargs, when it is used
> only as "(void*)NULL"?

Any program doing this will suffice, on a machine where not all pointer types
have the same internal null pointer representation (as a bitpattern).  Note
that this includes function pointers.


Segher


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