[PATCH] D33305: [ubsan] Add a check for pointer overflow UB

John Regehr via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 7 08:51:12 PDT 2017


regehr added a comment.

Sorry, let's go with this example instead, which makes it clear that the program is attempting to do something completely sensible:

  #include <stddef.h>
  
  typedef struct {
    int x[2];
  } T;
  
  int main(void) {
    T f[1000];
    T *p = &f[500];
    ptrdiff_t d = -10;
    p += d / sizeof(T);
    return 0;
  }


Repository:
  rL LLVM

https://reviews.llvm.org/D33305





More information about the cfe-commits mailing list