From: Segher Boessenkool > Sent: 16 April 2024 11:38 > > On Tue, Apr 16, 2024 at 03:02:52PM +0530, Naresh Kamboju wrote: > > In file included from arch/powerpc/include/asm/io.h:672: > > arch/powerpc/include/asm/io-defs.h:43:1: error: performing pointer > > arithmetic on a null pointer has undefined behavior > > [-Werror,-Wnull-pointer-arithmetic] > > It is not UB, but just undefined: the program is meaningless. > > It is not a null pointer but even a null pointer constant here. It > matters in places, including here. > > It would help if the warnings were more correct :-(
Isn't it only a problem because the NULL pointer isn't required to be the all-zero bit pattern? So when do we get a warning from using memset() on a structure that contains pointers? Since it is equally buggy. Has anyone ever seen a system where NULL wasn't 'all zeros'? I've used a system where the 'native' invalid pointer was 'all ones', but even there the C code used 'all zeros'. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)