Menu

#3874 Local variables that have their address taken in inline function definitions end up in asm

closed-fixed
inline (2)
other
5
2025-09-02
2025-09-01
No

When an inline function definition contains a static local variable that has its address taken, space is allocated for this variable, even if no code is emitted for the inline function. I.e. this file

extern void *m (void *p);

inline void l(void) {static unsigned char v; m (&v);}

Compiles into:

    .area DSEG    (DATA)
_l_v_10000_3:
    .ds 1

For ports, where --stack-auto is not the default, this also affects variables not declared static. This is a serious issue for those ports, as just including a header with some inline functions can easily result in running out of RAM.

Related

Feature Requests: #1000
Wiki: NGI0-Commons-SDCC

Discussion

  • Philipp Klaus Krause

    There is a partial fix in [r15645], that works for the example above (and the rotation functions from stdbit.h), but is not enough for some others (in particular the endian-aware load functions from stdbit.h).

     

    Related

    Commit: [r15645]


    Last edit: Philipp Klaus Krause 2025-09-02
  • Philipp Klaus Krause

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

    Fixed in [r15646].

     

    Related

    Commit: [r15646]


Log in to post a comment.

MongoDB Logo MongoDB