[llvm] [llvm] Fix __builtin_object_size interaction between Negative Offset … (PR #111827)

via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 17 23:57:25 PDT 2024


serge-sans-paille wrote:

```
% cat /tmp/a.c
#include <stdio.h>
int x, i = -1;
int main() {
  int array1[4];
  int array2[8];
  int *ptr;
  if (x) {
    ptr = array1;
  } else {
    ptr = array2 + 4;
  }
  printf("%zd\n", __builtin_dynamic_object_size(ptr + i, 0));
}
% ./bin/clang /tmp/a.c -o /tmp/a && /tmp/a
-1
```

which is totally fine (I've just changed the `printf` call to output signed value instead of unsigned in your example)

https://github.com/llvm/llvm-project/pull/111827


More information about the llvm-commits mailing list