[cc65] C64: local block variables corrupting stack

From: Dirk Jagdmann <doj1cubic.org>
Date: 2008-09-26 22:40:44
Hello compiler writers,

I've stumbled accross an issue with local block scoped variables. The
following test program should loop indefinitely, since variable "a"
should be 8 all the time. However when compiling with cc65 2.12.0 on the
second loop "a" is 16.

#include <conio.h>
int main()
{
  unsigned char a=8;
 jump_to_top:
  cprintf("a should be eight: %u\r\n", a);
  if(a==8)
    {
      unsigned char XXX;
      goto jump_to_top;
    }
  return 0;
}

If I remove the XXX variable from the inner block or move it to the main
block the program behaves correctly.

Is this a bug in the current release of cc65 or is the usage of block
local variables discouraged?

-- 
---> Dirk Jagdmann
----> http://cubic.org/~doj
-----> http://llg.cubic.org
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Fri Sep 26 22:40:39 2008

This archive was generated by hypermail 2.1.8 : 2008-09-26 22:40:41 CEST