Issue 235438
Summary llubi accepts an inbounds GEP starting outside its allocation
Labels new issue
Assignees
Reporter Roticv912
    An inbounds GEP starts outside an allocation, moves back into it, and is dereferenced without reporting undefined behavior.

### Program
```llvm
define i32 @main() {
  %p = alloca i8
 %outside = getelementptr i8, ptr %p, i64 2
  %q = getelementptr inbounds i8, ptr %outside, i64 -2
  %x = load i8, ptr %q
  ret i32 0
}
```

### Output
```
Entering function: main
  %p = alloca i8, align 1 => ptr 0x8 [p]
  %outside = getelementptr i8, ptr %p, i64 2 => ptr 0xA [p + 2]
  %q = getelementptr inbounds i8, ptr %outside, i64 -2 => ptr 0x8 [p]
  %x = load i8, ptr %q, align 1 => i8 0
  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