likeamahoney wrote:
> Hi, thanks for the report. This is the intended behavior AFAICT. My question
> is, why would you ever pass a dangling pointer to a function? I can't think
> of a valid use-case for doing that. They could just pass a null-pointer if
> they really wanted. Am I missing something?
Hi! Thank you for response! Sorry, I can’t come up with a good example of using
dangling pointers from real-world code, only exotic ones. I was just puzzled by
the fact that such an example with dangling pointer using doesn’t trigger a
warning from the checker, while, for example, the one from the topic raise "use
after free":
```c
#include "stdio.h"
#include "stdlib.h"
void test() {
int *p = (int*)malloc(sizeof(int));
free(p);
if (p) { // no warning
printf("smth");
}
```
[godbolt](https://godbolt.org/z/7z41GchPe)
https://github.com/llvm/llvm-project/pull/116383
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits