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]

 



On Wed, Jan 09, 2019 at 09:29:03PM +0000, Derek M Jones wrote:
> Luc,
> 
> > So if you want to use strictly standard C and avoid the warning
> > you have to use '{ NULL }'.
> 
> Using of 0 in this context does not make the source non-strictly
> conforming.
> 
> "An integer constant expression with the value 0, or such an
> expression cast to type void *, is called a null pointer constant."
> 
> http://c0x.coding-guidelines.com/6.3.2.3.html

Yes, sure, using 0 here is perfectly legal but sparse being what it is
(a C checker having stricter type checking than GCC and/or standard C)
it gives a an explicit warning when 0 is used to initialize (or compare
to) a pointer and the warning is enabled by default. This is quite
similar to GCC's -Wzero-as-null-pointer-constant but this last warning
is only valid for C++, not C.

Like, I'm asking on the other sub-thread, maybe this warning should be
relaxed. I don't know and don't have a strong opinion about it.

-- Luc



[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