Menu

#3356 [MOS6502] [S08] compiler crash when returning structs with size > 8

closed-fixed
None
HC08
5
2023-07-28
2022-03-16
No

compiler crash when returning structs larger than 8 bytes with:
error 9: FATAL Compiler Internal Error in file 'gen.c' line number '2015' : code generator internal error
sdcc -mmos6502 test.c

typedef struct {
  char a[9];
} s;

s func()
{
        s ret;
        ret.a[0]=1;
        return(ret);
}

both mos6502 and s08 port fail in similar ways.

Discussion

  • Philipp Klaus Krause

    Hmm. The hc08_aop_pass mechanism used for hc08 and s08 doesn't really allow for more than 8 bytes.

    Maybe switch to return via hidden parameter for larger values, like pdk does (pdk already does it for return values larger than 2 bytes)?

     

    Last edit: Philipp Klaus Krause 2022-03-16
  • Philipp Klaus Krause

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

    A while ago (in the next branch, since merged to trunk), I made this a proper error message instead of a compiler crash. Making it work is [feature-requests:#879].

     

    Related

    Feature Requests: #879


    Last edit: Philipp Klaus Krause 2023-07-28

Log in to post a comment.

MongoDB Logo MongoDB