C
A simple recursion. But where's the recursive call?!
NOTE: The include lines have a space in them, for "security" reasons. Edits are welcome.
#inc lude#include <stdio.h>
#inc lude#include <errno.h>
void f(int errno) {
if (errno==EINVAL) puts("EINVAL");
}
int *main() {
f(main);
return 0;
}
Solution:
errno.h
defines:#define errno *(__errno_location())
When this is expanded in the parameter list,f
is defined to get a function pointer parameter, named__errno_location
.
When this is expanded in the body, this function is called.
Callingf
withmain
as a parameter leads to endless recursion.
EDIT: The previous version crashed, but not because of a stack overflow. Fixed.