Tail rejection is indeed supported and enabled by default in the Arduino environment. This is quite standard in the microcontroller world, where debugging tools, such as the correct stack frames, are sacrificed for memory efficiency.
Here's the test:
const int RAM_SIZE_IN_BYTES = 2048; void f(int i) { Serial.println(i); if(i == 0) return; else f(i-1); } void setup() { Serial.begin(9600); f(RAM_SIZE_IN_BYTES); } void loop() { }
This code prints numbers from 2048 to 0 on the console, which requires more recursive calls than the available bytes of RAM.
source share