[chbot] GCC and recursion

Charles Manning cdhmanning at gmail.com
Fri Mar 29 20:43:37 GMT 2024


No, this should have nothing to do with gcc regardless of optimisation and
debug settings.
Optimisations should not stop properly constructed code from working.

I humbly submit that you are smashing the stack.
Stack smashing can potentially overwrite the return address causing the
sort of behaviour you are reporting.

If you're still stuck later, then maybe post some code and I or others can
perhaps help you out.

Regards

Charles




On Sat, Mar 30, 2024 at 6:57 AM Mark Atherton <markaren1 at xtra.co.nz> wrote:

> All,
>
> Haven't recursed for a number of years, so need some help.
>
> 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.
>
> Currently using "gcc version 12.2.0 (MinGW-W64 x86_64-ucrt-posix-seh,
> built by Brecht Sanders)"
>
> The first call of the recursed function worked fine, but crashes upon exit.
>
> It could be that the compiler is not generating re-entrant code. The
> only switch I have used is -O0 to disable compiler optimization.
>
> Are there any other switches for GCC that I need to use/be aware of ?
>
> Thanks, Mark
>
> _______________________________________________
> Chchrobotics mailing list Chchrobotics at lists.ourshack.com
> https://lists.ourshack.com/mailman/listinfo/chchrobotics
> Mail Archives: http://lists.ourshack.com/pipermail/chchrobotics/
> Meetings usually 3rd Monday each month. See http://kiwibots.org for
> venue, directions and dates.
> When replying, please edit your Subject line to reflect new subjects.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ourshack.com/pipermail/chchrobotics/attachments/20240330/2b5baed7/attachment-0001.html>


More information about the Chchrobotics mailing list