Another one from the land of z88dk, this was found with r12285, but also present in vanilla r12388:
#include <stdio.h>
typedef unsigned short uint16;
uint16 x, y;
static uint16 printHello() {
printf("\nHello");
return 1;
}
static uint16 hello(uint16 a, uint16 b) {
uint16 result = 0;
if(a + b > x - y){
result = printHello();
}
return result;
}
void main() {
x = 2000;
y = 1000;
hello(600,600);
}
We expect "Hello" to be printed, defective code generated is:
ld hl, #_y
ld a, (_x+0)
sub a, (hl)
ld h, a <<<<<
inc hl
ld a, (_x+1)
sbc a, (hl)
ld l, a
ld a, h
sub a, c
ld a, l
sbc a, b
Compilation:
Thanks. I can reproduce the issue on my Debian GNU/Linux testing system.
Fixed in [r12390].
Last edit: Maarten Brock 2021-05-22