Re: "Using plain integer as NULL pointer" false positive for zero struct initializer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all!

Not that I'm defending C++ in anyway (and sorry for somewhat off-topic):

On 10/01/2019 00:14, Linus Torvalds wrote:
[...]
> And yes, I realize that the C++ people completely screwed up, and
> originally doubled down on the old K&R C model of "NULL must be 0". It

Yup, because they would have to type-cast "(void*)0" everywhere ...

> took them a decade or more to understand just how wrong they were, but
> they finally got over it. It's C++, what can I say?

They finally fixed it with the "nullptr" symbol (and "nullptr_t" type of
it - which makes no sense in a pure C world).
----  snip  ----
#define nullptr (void*)0
----  snip  ----
in C, use it instead of "NULL" and that's it totally pure clean C since
K&R;-)
Something like that should actually have gone in some C standard ages
ago ....

> The fact that the C++ people had no taste, and the fact that a lot of
> C compilers have to dead with old per-K&R C and deal with header files
                      ^^^^ Freudian typo[0]? SCNR ...;-)
> and legacy programs that still assume "0 is a valid NULL pointer" is
> entirely immaterial.

There are situations (e.g. like execv() and friends) where it *is*
(always) a (with execv() a "char*") pointer context but the C-compiler
has no chance to know it because it's a variable argument list (except
with special handling on the name of the sys-call/funtion within the
compiler).

MfG,
	Bernd

[0]: Is that the English version of the German "Freud'scher
     Versprecher/Verschreiber"?
-- 
Bernd Petrovitsch                  Email : bernd@xxxxxxxxxxxxxxxxxxx
                     LUGA : http://www.luga.at



[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux