Cc65: [cl65, BUG] -Cl option does not work with recursive calls

Created on 23 Oct 2020  路  4Comments  路  Source: cc65/cc65

I'm not sure if it is a bug, but I could not find any hint in the documentation that the -Cl option comes with the limitation of recursive calls. An example

#include <stdint.h>
#include <stdio.h>

void caller(uint8_t param)
{
  uint8_t x = param - 1;

  if (x == 0) return;

  caller(x);
  printf("%u ", x);
}

int main(void)
{
  caller(10);

  return 0;
}

This should produce the output 1 2 3 4 5 6 7 8 9 correct without -Cl option. But if enabled the output is 0 0 0 0 0 0 0 0 0. The option itself does to do what expected, just the value of the deepest recursion call is the output. But I think there should be at least a big warning in the documentation and --help option.

Thanks for reading and have fun,
Dirk =D

question

Most helpful comment

https://github.com/cc65/cc65/commit/8e685a00717348d5b1af9cac180269b15fa25b71 :-)

All 4 comments

https://cc65.github.io/doc/cc65.html#ss2.2 says "[...] the code is no longer reentrant."

Maybe just adding the word recursion for the sake of clarity?
https://stackoverflow.com/questions/3052393/reentrancy-and-recursion

https://github.com/cc65/cc65/commit/8e685a00717348d5b1af9cac180269b15fa25b71 :-)

Thanks. It麓s really better for everyone :)

Greets and happy weekend xD

Was this page helpful?
0 / 5 - 0 ratings