[PATCH] D148827: -fsanitize=function: support C
Mike Hommey via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jun 14 13:26:02 PDT 2023
glandium added a comment.
In D148827#4379764 <https://reviews.llvm.org/D148827#4379764>, @MaskRay wrote:
> These cases are UB and should be caught. It's not an excuse that they use C.
Are they really though?
struct A {
int a;
};
int foo(struct A *a) { return 42; }
int bar(void *a) { return foo(a); }
int main(void) {
struct A a;
bar(&a);
int (*qux)(void *) = (int (*)(void *))foo;
qux(&a); // If this is UB, why isn't the call to foo from bar?
return 0;
}
Likewise for `int foo()` and `int bar(void)`/`int (*qux)(void)`.
Likewise for `struct A* foo(void)` and `void *bar(void)`/`void *(*qux)(void)` (surprisingly, clang doesn't emit this error for `struct A* foo()` and `void* bar()`/`void*(*qux)()`)
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D148827/new/
https://reviews.llvm.org/D148827
More information about the cfe-commits
mailing list