unit1309.c:91:24: error: arithmetic on a null pointer treated as a cast from integer to pointer is a GNU extension [-Werror,-Wnull-pointer-arithmetic]
nodes[i].payload = CURLX_INTEGER_TO_POINTER_CAST(payload);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../lib/warnless.h:32:26: note: expanded from macro 'CURLX_INTEGER_TO_POINTER_CAST'
((void *)((char *)NULL + (i)))
~~~~~~~~~~~~ ^
unit1309.c:125:34: error: arithmetic on a null pointer treated as a cast from integer to pointer is a GNU extension [-Werror,-Wnull-pointer-arithmetic]
nodes[i * 3 + j].payload = CURLX_INTEGER_TO_POINTER_CAST(payload);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../lib/warnless.h:32:26: note: expanded from macro 'CURLX_INTEGER_TO_POINTER_CAST'
((void *)((char *)NULL + (i)))
-Wnull-pointer-arithmetic now warns about performing pointer arithmetic on a null pointer. Such pointer arithmetic has an undefined behavior if the offset is nonzero. It also now warns about arithmetic on a null pointer treated as a cast from integer to pointer (GNU extension).
curl/libcurl version
$ git rev-parse HEAD
dd03e8c281582af454fabfb4a666a5b232d518aa
unit1309.c:91:24: error: arithmetic on a null pointer treated as a cast
from integer to pointer is a GNU extension
Reported-by: Rikard Falkeborn
Fixes#2466
#2468 fixes the reported warnings. However, if I enable gnutls (--with-gnutls) I get the same warning in the last place CURLX_INTEGER_TO_POINTER_CAST is used:
CC vtls/libcurl_la-gtls.lo
vtls/gtls.c:851:21: error: arithmetic on a null pointer treated as a cast from integer to pointer is a GNU extension [-Werror,-Wnull-pointer-arithmetic]
transport_ptr = CURLX_INTEGER_TO_POINTER_CAST(conn->sock[sockindex]);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../lib/warnless.h:32:26: note: expanded from macro 'CURLX_INTEGER_TO_POINTER_CAST'
((void *)((char *)NULL + (i)))
~~~~~~~~~~~~ ^
1 error generated.
Note that there is not warning from CURLX_POINTER_TO_INTEGER_CAST.
unit1309 and vtls/gtls: error: arithmetic on a null pointer treated as a
cast from integer to pointer is a GNU extension
Reported-by: Rikard Falkeborn
Fixes#2466
I did this
Built curl with clang 6.0.0.
I expected the following
Successful build. Instead, I got this:
Looks like this warning has been improved/changed in clang 6. From http://releases.llvm.org/6.0.0/tools/clang/docs/ReleaseNotes.html#improvements-to-clang-s-diagnostics
curl/libcurl version
operating system
Linux (Arch Linux)
The text was updated successfully, but these errors were encountered: