Re: [cc65] Compiler Issue

From: Ullrich von Bassewitz <>
Date: 2011-04-12 21:52:20

On Tue, Apr 12, 2011 at 03:07:58PM +0200, Oliver Schmidt wrote:
> 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.

Yes, variables in local blocks in combination with jumps are broken. Here is
another piece of code that doesn't work:

    int foo = 1;
    while (foo) {
        int bar = 1;
        if (bar) {
            goto faz;
faz: ;

This has been broken since ages (version 2.4 or similar) and no one has
complained so I almost forgot about it:-)

The compiler can be fixed for the code shown above with not too much effort.
But the code you posted is a different thing, because it would be required to
move allocation of variables to the top of the function, and this doesn't
really fit into the compiler as it is now. Maybe I can at least make this an
error ..

Thanks for the report!



Ullrich von Bassewitz                        
To unsubscribe from the list send mail to with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Tue Apr 12 21:52:29 2011

This archive was generated by hypermail 2.1.8 : 2011-04-12 21:52:32 CEST