alive2 icon indicating copy to clipboard operation
alive2 copied to clipboard

A load outside an inrange subrange is accepted

Open Forever119 opened this issue 2 weeks ago • 0 comments

A load at offset 2 from a pointer with inrange(0,1) returns 99 without an undefined-behavior diagnostic.

Program

@g = private constant [4 x i8] c"abcd"
define i32 @main() {
  %q = getelementptr i8, ptr getelementptr inrange(0, 1) ([4 x i8], ptr @g, i64 0, i64 0), i64 2
  %x = load i8, ptr %q
  %r = zext i8 %x to i32
  ret i32 %r
}

Output

Executing %#0
%__constexpr_0 = #b00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000
%q = #b00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000001000000000
%x = #x63
%r = #x00000063
Returned #x00000063 / non-poison=true

Forever119 avatar Nov 19 '26 14:11 Forever119