[cc65] Compiler Issue

From: Oliver Schmidt <ol.sc1web.de>
Date: 2011-04-12 15:07:58
Hi,

Maybe it's obvious to everybody but me... However check out the
following program:

====================

void sub(int x, int y)
{
  printf("a: %d %d\n", x, y);
  goto label;

  {
    int dummy;

label:
    printf("b: %d %d\n", x, y);
  }
}

void main(void)
{
  sub(47, 11);
}

====================

The second printf() doesn't print the expected values 47 and 11
because at that point the stack pointer doesn't match the expectations
of the generated code.

The reason is that the goto skipped the definition of the scope-local
variable. Therefore the stack pointer stays unaltered while the code
behind the scope-local variable assumes it to have been altered by the
scope-local variable definition.

Regards,
Oliver
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Tue Apr 12 15:08:06 2011

This archive was generated by hypermail 2.1.8 : 2011-04-12 15:08:10 CEST