The problem
Using gcc (Ubuntu 15.2.0-16ubuntu1) 15.2.0 under WSL of Windows11 with the forsp demo.fp I got a segmentation fault.
I'm quite sure, that lots of compiler versions and forsp programs will show the same problem.
The solution
I fixed read_list as follows:
...
obj_t *evaluate_first = read();
return make_pair(evaluate_first, read_list());
// return make_pair(read(), read_list());
The reason
The order of evaluation is unspecified in C. So even the next compiler version on the same platform might decide to evaluate read_list before evaluating read. This leads to a stack overflow which in turn leads to undefined behaviour.
The problem
Using gcc (Ubuntu 15.2.0-16ubuntu1) 15.2.0 under WSL of Windows11 with the forsp demo.fp I got a segmentation fault.
I'm quite sure, that lots of compiler versions and forsp programs will show the same problem.
The solution
I fixed read_list as follows:
...
The reason
The order of evaluation is unspecified in C. So even the next compiler version on the same platform might decide to evaluate
read_listbefore evaluatingread. This leads to a stack overflow which in turn leads to undefined behaviour.