Another bug found

Bug reports (if you don't/won't have a Github account)
Post Reply
zx64
New member
Posts: 6
Joined: Thu Apr 29, 2021 2:45 am

Another bug found

Post by zx64 »

Code: Select all

#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);
}
Compiled it with latest build like this

Code: Select all

 zcc +zx -vn -clib=sdcc_ix --max-allocs-per-node10000 -startup=0 .\Bug.c -o bug -create-app 
It's expected to print Hello, but it doesn't. Changing options to --max-allocs-per-node0 fixes the problem
stefano
Well known member
Posts: 2137
Joined: Mon Jul 16, 2007 7:39 pm

Re: Another bug found

Post by stefano »

The problem vanishes if you switch to "-clib=sdcc_iy", I see that with sdcc_ix, the way to deal with the hello() function parameters changes radically.
Post Reply