RE: [kbuild-all] Re: net/ceph/messenger_v2.c:2808:5: warning: stack frame size (2336) exceeds limit (2048) in function 'ceph_con_v2_try_read'

From: David Laight
Date: Mon Jun 28 2021 - 04:24:21 EST


...
> >> arch/powerpc/include/asm/io-defs.h:43:1: warning: performing pointer arithmetic on a null
> pointer has undefined behavior [-Wnull-pointer-arithmetic]

I've just realised why that error is output.
The result of (long)((char *)0 + 4) is only 4 if the NULL pointer
has the 'all-zero' bit pattern.
This isn't mandated by the language.

However I suspect almost every implementation of C there has ever
been has used the all-zero bit pattern for NULL.
This includes one system I used (many years ago) where the 'natural'
NULL pointer would have been the all-ones pattern.

Far too much code assumes memset(ptr, 0, len) will set pointers
to NULL for any other value to ever work.

Of course 'undefined behaviour' doesn't mean 'undefined value'
it includes firing a ICBM at the coder's house.

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)