Re: [cc65] C64: local block variables corrupting stack

From: Groepaz <groepaz1gmx.net>
Date: 2008-09-26 23:01:40
On Freitag 26 September 2008, Dirk Jagdmann wrote:
> 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?

thats definetly a bug to me :) generally, assume that valid C should also 
compile and work as expected. (even if this kind of code is kindof ugly =P)

-- 

http://www.hitmen-console.org
http://www.pokefinder.org
http://ftp.pokefinder.org

Java is high performance. By high performance we mean adequate. By adequate we 
mean slow. 
<Mr. Bunny>

----------------------------------------------------------------------
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:59:45 2008

This archive was generated by hypermail 2.1.8 : 2008-09-26 22:59:48 CEST