This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Preliminary mainline patch for __attribute__ ((sentinel))
- From: "Kaveh R. Ghazi" <ghazi at caip dot rutgers dot edu>
- To: espie at nerim dot net
- Cc: gcc-patches at gcc dot gnu dot org, jsm at polyomino dot org dot uk
- Date: Tue, 14 Sep 2004 20:44:26 -0400 (EDT)
- Subject: Re: Preliminary mainline patch for __attribute__ ((sentinel))
- References: <200408281518.i7SFIFu9015822@caip.rutgers.edu> <Pine.LNX.4.61.0408281525140.4806@digraph.polyomino.org.uk> <200408281702.i7SH2q7O028876@caip.rutgers.edu> <Pine.LNX.4.61.0408281709070.5830@digraph.polyomino.org.uk> <200408281839.i7SIdV6A013866@caip.rutgers.edu> <20040914092843.GA9401@tetto.gentiane.org> <200409141301.i8ED1IPj012720@caip.rutgers.edu> <20040914161013.GC20574@tetto.gentiane.org>
> > 4. Leave the warning as is, and fix all calls to concat in gcc
> > (other source code using sentinels will still have the problem.)
>
> This is my preferred approach, and I will explain why.
>
> ISO C doesn't guarantee that NULL be a pointer. It can be any kind of
> integral zero instead (we know that C++ is different).
>
> Allowing people to keep their NULL being 0 (or 0L, actually, for
> OpenBSD) allows us to be very picky about portable code: our sentinel
> does insist that you explicitly write a null pointer for code
> termination, and it isn't satisfied by our definition of NULL. Mind
> you, our NULL is specifically 0L to make sure the code still works: 0L
> is exactly the size of a pointer on all architectures that OpenBSD
> does support.
>
> So, we get working code, until we fix the warning, and then we get
> portable code.
Portable to where exactly? I think it's worth asking, can you name
one single platform where NULL is not suitably defined to pass in lieu
of a pointer through a variadic function call?
I think it's also relevant but not pivotal whether is GCC supported on
that platform.
Unless you can name one, I think #4 is busy-work with no realizable
benefit. (Note you'll have to change all users of libiberty like GDB
and BFD, not just GCC. I.e. anywhere we have a call site for concat
et al.)
If you really think it's useful, be my guest. I think your efforts
are better spent on option #2 from my previous message.
--Kaveh
--
Kaveh R. Ghazi ghazi@caip.rutgers.edu