[chbot] GCC and recursion

Mark Atherton markaren1 at xtra.co.nz
Sat Mar 30 00:25:28 GMT 2024


All,

The cross assembler is x86 based, has a deterministic exit condition, 
and debug code showing return values. It only exits once, hence checking 
compiler constraints before looking closer look for stupidity on my part.

Thanks for all the comments.

Mark

On 3/30/2024 12:15 PM, Volker Kuhlmann wrote:
>> I am building an RPN expression evaluator for the uCPU assembler; I can't
>> see any other way to go other than to use recursion to do the nested
>> processing that I wish.
> 
> I agree that that should have nothing to do with gcc, although it is
> possible that gcc has quite a few bugs affecting correct code generation
> for some µC cores. Those are gcc version dependent too.
> 
> What architecture are you generating code for? Is your assembler running
> on x86? It's safe to assume for that that crashes are caused by your
> code, not gcc.
> 
> Recursive programming relies on having a reliable exit condition, taken
> before resources like stack run out. An easy way to check is to write
> out the parameters for each call on a single line, one line per call,
> and any unrestrained criteria show up at the bottom of the screen.
> 
>> It could be that the compiler is not generating re-entrant code.
> 
> Not for x86. More likely a variable which changes with each call is not
> local. A compiler bug, if it's for esoteric cores, would still be down
> on my list.
> 
> Why don't you just compile for x86 and test in a high-resource
> environment first?
> 
> Volker
> 




More information about the Chchrobotics mailing list