Menu

#3060 [z80,hc08] SIGSEGV on initilaizing global with casted pointer to struct

closed-fixed
None
other
5
2023-02-04
2020-06-14
No
struct s
{
    int a;
};

struct s x;
int y = ((struct s*)&x)->a;

Compiling this with sdcc test.c -mz80 yields Caught signal 11: SIGSEGV. Tested with commit 11672.

Related

Wiki: NGI0-Entrust-SDCC

Discussion

  • Philipp Klaus Krause

    • summary: [z80] SIGSEGV on initilaizing global with casted pointer to struct --> [z80,hc08] SIGSEGV on initilaizing global with casted pointer to struct
     

    Related

    Wiki: z80

  • Philipp Klaus Krause

    I can reproduce the issue on my Debian GNU/Linux testing system. On z80, hc08, s08, r2k, z180 (oddly not on gbz80).

     
  • Sergey Belyashov

    Is it valid construction for C? As I know, you cannot assing value of one global variable to another one, am I wrong?

     
    • Philipp Klaus Krause

      It is not valid C. But SDCC should give a proper error message ("Initializer element is not a constant expression") rather than crash.

      P.S.: I noticed that for

      int i;
      int j = i;
      

      SDCC does crash, too. But at least it gives the proper error message first.

       
  • Sebastian Riedel

    Still a SIGSEGV on 4.2.0, now also for sm83

     
  • Philipp Klaus Krause

    Fixed in [r13852].

     

    Related

    Commit: [r13852]

  • Philipp Klaus Krause

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

Log in to post a comment.

MongoDB Logo MongoDB