Re: [cc65] ca65 assembler internal error

From: Ullrich von Bassewitz <uz1musoftware.de>
Date: 2014-04-16 15:13:44
Hi!

On Mon, Apr 14, 2014 at 11:54:39PM -0400, Jeremy Turner wrote:
>    I'm getting the error:
>    ca65: Precondition violated: Index < C->Count, file `common\coll.h', line 155

At first glance, replacing S->DefLines with Sym->DefLines in SymCheckUndefined
will fix the problem. Since S is the undefined symbol while Sym is the defined
one, S->DefLines will always be empty, so using it here is definitely wrong.

Considering it more carefully, I cannot think of a situation where we have an
undefined and a defined symbol, both exported, but the undefined one has an
actual address size assigned. Which means that the address size will always be
ADDRSIZE_DEFAULT and will trigger the error message. So you're probably right
and the whole check can be removed:

------------------------------------------------------------------------------
Index: symtab.c
===================================================================
--- symtab.c	(revision 5990)
+++ symtab.c	(working copy)
@@ -505,17 +505,7 @@
                          "Symbol `%s' is already an import",
                          GetString (Sym->Name));
 	    }
-            if (Sym->Flags & SF_EXPORT) {
-                /* The symbol is already marked as an export. */
-                if (Sym->AddrSize > S->ExportSize) {
-                    /* We're exporting a symbol smaller than it actually is */
-                    LIWarning (&S->DefLines, 1,
-                               "Symbol `%m%p' is %s but exported %s",
-                              GetSymName (Sym),
-                              AddrSizeToStr (Sym->AddrSize),
-                              AddrSizeToStr (S->ExportSize));
-                }
-            } else {
+            if ((Sym->Flags & SF_EXPORT) == 0) {
                 /* Mark the symbol as an export */
                 Sym->Flags |= SF_EXPORT;
                 Sym->ExportSize = S->ExportSize;
@@ -525,7 +515,7 @@
                 }
                 if (Sym->AddrSize > Sym->ExportSize) {
                     /* We're exporting a symbol smaller than it actually is */
-                    LIWarning (&S->DefLines, 1,
+                    LIWarning (&Sym->DefLines, 1,
                                "Symbol `%m%p' is %s but exported %s",
                                GetSymName (Sym),
                                AddrSizeToStr (Sym->AddrSize),
------------------------------------------------------------------------------

Regards


        Uz


-- 
Ullrich von Bassewitz                                  uz@musoftware.de
Encrypted email preferred                          PGP Key-Id: 29D93B10
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Wed Apr 16 15:13:58 2014

This archive was generated by hypermail 2.1.8 : 2014-04-16 15:14:00 CEST