Re: [cc65] Optimizer bug found

From: Ullrich von Bassewitz <uz1musoftware.de>
Date: 2009-09-13 17:54:36
Ok, finally ...

On Fri, Sep 11, 2009 at 07:35:22PM +0200, Groepaz wrote:
> - yacc.c works when optimizations are disabled. its still broken in all other
> cases :/ and most annoyingly: when i enable debug output in yacc.c, it still
> works in all cases, so tracking down the bug is kinda tedious =P

I found the problem and fixed it. cc65 treated a label as a statement, but the
standard says, that a label is part of a statement. In a loop without curly
braces like

        while (foo < bar)
            label:  ++foo;

the following statement is the one that is looped over - and because cc65
treated just the label as a statement, it created code that looped forever.

This was really a tough one. yacc.c is one of the worst program I've seen in
years. After fixing the bug in the compiler, I've spent more than an hour to
verify that all other problems are in yacc.c - because the behaviour changed,
but it still did not run.

Not only line feeds are hardcoded, the program is somehow using char codes
instead of numeric constants. I had to replace the 'A' character literals in
the table by their ASCII code (0x41) to make the program work. With the cc65
character translation in place, 0xC1 was used instead, which broke the program
logic somehow. So if you want to keep the program in the test suite (which is
a good idea), you will have to fix at least the most unportable things. I can
send you my working version, which has also improved debug output.

Regards


        Uz


-- 
Ullrich von Bassewitz                                  uz@musoftware.de
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Sun Sep 13 17:56:49 2009

This archive was generated by hypermail 2.1.8 : 2009-09-13 17:56:51 CEST