Issue 235721
Summary llubi accepts a freed pointer as a dereferenceable argument
Labels new issue
Assignees
Reporter Roticv912
    A freed heap pointer is passed to a dereferenceable(1) parameter and the callee returns normally without reporting undefined behavior.

### Program
```llvm
declare ptr @malloc(i64)
declare void @free(ptr)
define void @f(ptr dereferenceable(1) %p) { ret void }

define i32 @main() {
entry:
  %p = call ptr @malloc(i64 1)
  call void @free(ptr %p)
  call void @f(ptr %p)
  ret i32 0
}
```

### Output
```
Entering function: main
  %p = call ptr @malloc(i64 1) => ptr 0x10 [p]
  call void @free(ptr %p)
Entering function: f
  ptr %p = ptr 0x10 [p (dangling)]
  ret void
Exiting function: f
 call void @f(ptr %p)
  ret i32 0
Exiting function: main
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to