- Notifications
You must be signed in to change notification settings - Fork14.5k
Closed
Description
The following code w/ ToT LLVM (clang-15) produces the following warnings:
void*x(void) {return (char*)0+42;}void*y(void) {return (void*)0+42;}
<source>:2:21: warning: arithmetic on a null pointer treated as a cast from integer to pointer is a GNU extension [-Wnull-pointer-arithmetic] return (char*)0 + 42; ~~~~~~~~ ^<source>:6:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] return (void*)0 + 42; ~~~~~~~~ ^
for the Linux kernel, we're using-std=gnu11 -Wno-gnu
, so we should not be observing ANY warnings that we're using GNU C extensions.
I suspect that these two checks should be split into two different named command line flags, such that the one pertaining to GNU C extensions is placed within the-Wgnu
flag group, such that-Wno-gnu
implicitly disables it.
(link#4440)
As reported inthis thread.