Menu

#3031 SIGSEGV on initializing float with non-constant int

closed-fixed
None
other
5
2022-05-10
2020-06-07
No
int i;
float d = i;

Compiling this with sdcc test.c results in Caught signal 11: SIGSEGV. Tested with commit 11647.

Related

Wiki: SDCC-STD-UX

Discussion

  • Erik Petrich

    Erik Petrich - 2020-06-15

    This is a problem with trying to generate the function call to the compiler helper function for the int to float cast without being in the context of an actual function. The C standard, at least up to C99, only requires support for a constant initializer so I am inclined just to abort the associated code generation after the "Initializer element is not a constant expression" error message. On the other hand, we could synthesize a function context for all the global initializers if we really wanted to support this (this could also fix bug [#2004]). Any other devs have opinions?

     

    Related

    Bugs: #2004

    • Philipp Klaus Krause

      Same in the N2479 C2X draft: "All the expressions in an initializer for an object that has static or thread storage duration shall be constant expressions or string literals."
      E_CONST_EXPECTED is fine for me.

       
      • Maarten Brock

        Maarten Brock - 2020-06-15

        I agree. An error is sufficient.

         
  • Gabriel Ravier

    Gabriel Ravier - 2020-06-16

    Yeah, what I consider to be a bug here is the SIGSEGV, not the fact that it would error on a correct implementation.

     
  • Sergey Belyashov

    • status: open --> closed-fixed
     
  • Sergey Belyashov

    Issue does not appear in r11795.

     
    • Philipp Klaus Krause

      I still get the SIGSEGV in [r11795] on my Debian GNU/Linux testing system.

       
  • Philipp Klaus Krause

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

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

    Fixed in [r13427].
    No regression test added yet, due to [bugs:#3383]

     

    Related

    Bugs: #3383
    Commit: [r13427]


Log in to post a comment.

MongoDB Logo MongoDB