Open
Description
Code to reproduce
routine power(number : integer, to_power : integer) : integer is
var tmp is 1;
if to_power < 1 then
return 1;
end
for i in 0 .. to_power - 1 loop
tmp := tmp * number;
end
return tmp;
end
routine main(input : integer) is
println power(2, 3);
return;
end
Expected behavior
Prints 8
Actual behavior
[LLVM]: [WARNINGS]:
Terminator found in the middle of a basic block!
label %then
ir.ll:38:3: error: instruction expected to be numbered '%1'
%0 = load i64, i64* %tmp
^
1 error generated.
Error generating IR
Comments
- Return statements inside basic basic blocks (if/else label, for loop) always produce that warning, sometimes the program still work, but it's better to invistigate that issue as it might be the root cause.
- Related question