forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 345
Open
Description
Tested on the latest version (as of today) on Linux:
$ clang-fbound -v
clang version 22.0.0git (https://github.com/swiftlang/llvm-project.git 54d626d2454f3821661d541bea933cb97122e255)
Target: x86_64-unknown-linux-gnu
Normal "-O3" produces a correct binary:
$ clang-fbound -O3 abc.c ; ./a.out
0
With "bounds-safety" and "-O3", it produces an incorrect binary:
$ clang-fbound -O3 -fbounds-safety abc.c ; ./a.out
1
The test C program:
$ cat abc.c
#include <ptrcheck.h>
int printf(const char *, ...);
static int a, c;
static char b[] = {228, 228};
static long d(void) {
unsigned e = 0;
for (; e <= 7; e++)
;
for (;;) {
a = 0;
for (; a <= 5; a++) {
if (b[a]) {
c = e <= 0;
return 8;
}
e = 1;
}
}
}
int main(void) {
d();
printf("%d\n", c);
}
Metadata
Metadata
Assignees
Labels
No labels