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


>>>>> "Richard" == Richard Henderson <rth@redhat.com> writes:

 Richard> On Wed, Oct 09, 2002 at 12:09:03AM -0300, Alexandre Oliva
 Richard> wrote:
 >> Since C++ requires NULL to not be a pointer type, when you pass
 >> NULL through an ellipsis, you probably end up with a type
 >> different than what you expected.  You pretty much have to cast
 >> NULL to the right pointer type in order to guarantee you get the
 >> right thing on the other end.

 Richard> I've now read through the entire thread.

 Richard> In my opinion and C implementation that does not define NULL
 Richard> such that it is either a void* or a pointer-sized integer is
 Richard> broken.  While such a thing might be technically within the
 Richard> letter of the law, it is extremely surprising, and will
 Richard> break more code than I care to imagine.

So are you saying that the C standard's statement that  0  is a valid
way to say "NULL pointer" is wrong, and anyone who relies on it is
writing broken code?

A quick scan of /usr/include on my Linux box shows a fair number of
header files that have that definition.

Or are you saying that variadic function parameter passing should
promote integers to be at least pointer sized, to avoid this issue?
That sounds fine.

     paul


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