For the attached sample, the calls inside the innermost _generic are not inlined.
While the code sample might look exotic at first sight, this bug is a real problem for us: the sample has been created when tracking down the underlying cause of a major strtoul code size regression: [feature-requests:#872].
Looks like this won't be easy to solve: We currently inline before we expand _Generic, and at the time of inlining, we don't have a symbol for the function in this call yet (it is still and AST node of type GENERIC).
Please consider the attached candidate patch to implement the requested feature and undo the workaround in
stdckdint.h. The fix seems pleasingly self-contained: it adds an extra conditional block on entry toexpandInlineFuncs, to resolve a generic callee before looking for an inline function symbol.As previously noted, the patch for [bugs:#4113] is a prerequisite for applying the proposed patch to implement inlining, otherwise reverting the workaround in
stdckdint.hprovokes errors in checked arithmetic.Related
Bugs: #4113
Last edit: Christopher Bazley 1 day ago
Please find a revised candidate patch attached. A fresh library build showed undefined-identifier errors in checked arithmetic inside
strtoul.This new version marks declarations in scope during inline function expansion and adds tests for nested blocks and shadowed variable declarations (in support/regression/tests/generic-inline.c) and checked arithmetic (in support/valdiag/tests/generic-inline.c).
The revised fix for [bugs:#4113] is still a prerequisite.
Related
Bugs: #4113
Ticket moved from /p/sdcc/bugs/3602/
Can't be converted:
Moving to feature requests as it is more an efficiency issue than a bug.
While working on [bugs:#3952], I noticed a workaround in
stdckdint.hwhich avoids using_Genericin the way intended by its designer (to select a function before calling it), for performance reasons relating to this feature request. In turn, that workaround required me to add casts that I would rather not have added because they undermine type safety.I think that fixing [bugs:#4113] is a prerequisite for implementing this feature request, otherwise reverting the workaround in
stdckdint.hprovokes errors in checked arithmetic.Related
Bugs: #3952
Bugs: #4113