Messages in this thread | | | Subject | Re: [PATCH v2] acpica: fix -Wnull-pointer-arithmetic warnings | From | Qian Cai <> | Date | Mon, 29 Jul 2019 08:23:57 -0400 |
| |
> On Jul 29, 2019, at 6:24 AM, David Laight <David.Laight@ACULAB.COM> wrote: > > From: Moore, Robert >> Sent: 26 July 2019 20:36 > ... >> This is because pointer arithmetic >> on a pointer not pointing to an array is an undefined behavior (C11 6.5.6, constraint 8). > ... > > The standards committee as smoking dope again :-) > If that is enforced as a compiler warning/error a lot of code 'breaks'. > Anything that does: > struct foo *foo = ...; > struct bar *bar = (void *)(foo + 1); > suddenly becomes 'invalid’.
The clang will generate a warning only if “foo" is NULL.
| |