3 ms·
"4.13.4 Function Invocation AV Rule 119 (MISRA Rule 70) Functions shall not call themselves, either directly or indirectly (i.e. recursion shall not be allowed)
by smutticus 13y ago
"4.13.4 Function Invocation
AV Rule 119 (MISRA Rule 70)
Functions shall not call themselves, either directly or indirectly (i.e. recursion shall not be
allowed)."
That's too bad.
- barkingcat 13y agoThat's a good rule for embedded software on a jet though. I can see why they'd do that.
- AnimalMuppet 13y agoNot if you want provable worst-case stack sizes (function call times). [Edit: or function call times]
- SoftwareMaven 13y agoUnexpectedly running out of stack space at Mach 1 while pulling a 5g maneuver is a little different than unexpectedly running out of stack space while playing tetris. Most recursion can be rolled into loops, so it's not completely limiting.
- Jtsummers 13y agoThe rationale is sensible though. C/C++ do not have tail call optimization, recursion reduces available stack memory which is a limited resource. By barring recursion, note they also bar malloc after initialization, they allow the program's memory usage to be determined at compile time, rather than during runtime. This allows them to satisfy requirements like "shall not use more than 50% of memory" (NB: this doesn't mean it will never use more than 50%, that extra memory available allows them to modify the program in the future and relax the memory constraint as needed without needing to modify hardware).