[PATCH] D98798: Produce warning for performing pointer arithmetic on a null pointer.

Nico Weber via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed May 12 08:13:35 PDT 2021


thakis added a comment.

Two pieces of feedback:

1. This fires in system headers on windows, e.g. like so:

  ../../third_party/wtl/include\./atlapp.h(336,12): error: performing pointer arithmetic on a null pointer has undefined behavior if the offset is nonzero [-Werror,-Wnull-pointer-arithmetic]
                          uSize = LVGROUP_V5_SIZE;
                                  ^~~~~~~~~~~~~~~
  ..\..\third_party\depot_tools\win_toolchain\vs_files\20d5f2553f\Windows Kits\10\Include\10.0.19041.0\um\commctrl.h(4074,25): note: expanded from macro 'LVGROUP_V5_SIZE'
  #define LVGROUP_V5_SIZE CCSIZEOF_STRUCT(LVGROUP, uAlign)
                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  ..\..\third_party\depot_tools\win_toolchain\vs_files\20d5f2553f\Windows Kits\10\Include\10.0.19041.0\um\commctrl.h(262,90): note: expanded from macro 'CCSIZEOF_STRUCT'
  #define CCSIZEOF_STRUCT(structname, member)  (((int)((LPBYTE)(&((structname*)0)->member) - ((LPBYTE)((structname*)0)))) + sizeof(((structname*)0)->member))
                                                                                           ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~

Can we make this not fire for macros for system headers? And if this takes a while to implement, can we revert this until then?

2. This reusing the existing group means we now either have to disable the old, existing warning and regress, or we can't build. Can we please put this in a new group (Wnull-pointer-arithmetic-sub or what) that's a subgroup of Wnull-pointer-arithmetic but that can be turned off separately, to allow incremental roll-out of this?

Thanks!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D98798/new/

https://reviews.llvm.org/D98798



More information about the cfe-commits mailing list