Menu

#3577 error 9: FATAL Compiler Internal Error

closed-out-of-date
None
Z80
1
2023-11-10
2023-04-30
Jeff Bill
No

I was making a game for the gameboy using the GBDK(which uses sdcc) and I ran into this error:

error 9: FATAL Compiler Internal Error in file '/Users/sdcc-builder/build/sdcc-build/orig/sdcc/src/z80/gen.c' line number '1870' : Symbol in register, but no register assigned. 
Contact Author with source code
Symbol iTemp46 at ic 73.
Caught signal 11: SIGSEGV

My code uses a few structs 1 array and I tried to take away any syntax sugar but to no avail. If you want to see the source let me know.

Discussion

  • Philipp Klaus Krause

    In which version of sdcc did you see the error? Does it still happen with a current version of sdcc?

    This looks like an error message from code generation. Most of the time, such errors can be reproduced using a source file containing only the function in which the error is triggered.

    Can you reproduce the error using a file with minimal dependencies (i.e. without gbdk)?

     
  • Jeff Bill

    Jeff Bill - 2023-04-30

    This error only happens with the sdcc shipped with GBDK I have made been able to recreate this without the GBDK headers. If you would like I can give you my source code.

     
    • Jeff Bill

      Jeff Bill - 2023-04-30

      I only included stdio.h

       
    • Jeff Bill

      Jeff Bill - 2023-04-30

      I have narrowed it down to where it gives the fatal error when iterating over an array.

       
      • Philipp Klaus Krause

        So you now have a single function that reproduces the issue, and the only #include is stdio.h?
        Could you show that source?

         
    • Philipp Klaus Krause

      I don't know which sdcc comes with your gdbk. What is the output of sdcc --version?

       
  • Jeff Bill

    Jeff Bill - 2023-05-01

    Here is the source code:

    #include <stdio.h>
    
    struct Vec3D{
        int x, y, z;
    };
    
    int cos(int x){
        int result = 1;
        int term = 1;
    
        for (int i = 1; i <= 10; i++) {
            term = term * (-1) * x * x / ((2 * i) * (2 * i - 1));
            result = result + term;
        }
    
        return result;
    }
    
    int sin(int x) {
        int result = 0.0;
        int term = x;
    
        for (int i = 1; i <= 10; i += 2) {
            result = result + term;
            term = term * -(x * x) / (i * (i + 1));
        }
    
        return result;
    }
    
    struct Vec3D points[4];
    
    int projection[2][3] = {
        {1, 0, 0},
        {0, 1, 0}
    };
    
    struct Vec3D matrixMult(int projection[2][3], struct Vec3D v){
        struct Vec3D res;
    
        res.x = projection[0][0] * v.x + projection[0][1] * v.y + projection[0][2] * v.z;
        res.y = projection[1][0] * v.x + projection[1][1] * v.y + projection[1][2] * v.z;
    
        return res;
    }
    
    struct Vec3D projected2D;
    struct Vec3D rotated;
    
    void main(){
    
        int rotation[2][3] = {
            {cos(0), -sin(0), 0}, 
            {sin(0), -cos(0), 0}
        };
    
        points[0].x = 25; points[0].y = 25; points[0].z = 0;
        points[1].x = 50; points[1].y = 25; points[1].z = 0;
        points[2].x = 50; points[2].y = 50; points[2].z = 0;
        points[3].x = 25; points[3].y = 50; points[3].z = 0;
    
        while(1){
            for(int i = 0; i < 4; i++){
                projected2D = matrixMult(projection, points[i]);
                rotated = matrixMult(rotation, projected2D);
            }
        }
    
    }
    

    According to GBDK it uses SDCC build #12539.

     
    • Philipp Klaus Krause

      When I compile that source on my Debian GNU/Linux testing system via

      sdcc -msm83 test.c
      

      using sdcc 4.2.14 #14011, I do not see the error.

       

      Last edit: Philipp Klaus Krause 2023-05-02
    • Philipp Klaus Krause

      There are struct parameters and return values in your code. That was not yet supported in sdcc #12539, so the sdcc you use must be a newer version.

       
  • Philipp Klaus Krause

    • status: open --> closed-rejected
    • assigned_to: Philipp Klaus Krause
     
  • Philipp Klaus Krause

    • status: closed-rejected --> closed-out-of-date
     

Log in to post a comment.