This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB 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: [commit] Properly cast sentinels for concat()


> Date: Mon, 4 Jul 2005 15:36:05 +0200
> From: Mark Kettenis <kettenis@jive.nl>
> 
> This fixes a few warnings with GCC 4.0 on OpenBSD.  You'll probably
> won't see them on other systems, since they only show up if NULL is
> defined as an integer instead of a pointer constant (both are valid
> according to C standard).  The stddef.h that comes with GCC defines
> NULL as (void *)NULL, but we don't use that one on OpenBSD.
> 
> Anyway, I committed the attached patch as obvious.

Actually, it's not at all obvious, it's IMNSHO simply wrong.  Casting
NULL to _anything_ should never be needed, unless NULL is abused
(i.e. used in a place where a pointer cannot be).  Let's not decide
that a patch is ``obvious'' just because it happens to shut up the
compiler!

In this case, I'd say it's a bug in OpenBSD (it _should_ use stddef.h
that comes with GCC when a program is compiled with GCC), coupled with
the silly attitude of latest GCC versions to whine about more and more
perfectly valid C code constructs.

Since these are warnings, I urge you to undo the ugly casts, and
instead ask the maintainers of the OpenBSD port of GCC to arrange for
the right stddef.h to be used.  With any luck, this will be fixed in
GCC 4.01 or some such, and until then let there be warnings on
OpenBSD.

(FWIW, in DJGPP we went through the same ordeal a few years ago, and
the solution was simple: let GCC use its stddef.h, and define NULL in
our own headers conditionally on it still being undefined.)


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