seltzered / ccons

Automatically exported from code.google.com/p/ccons
MIT License
0 stars 0 forks source link

Segmentation fault with recursive function #14

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. #include <stdio.h>
2. int test(int n) {
...   if(n==1) return 1;
...   return n+test(n-1);
...   }
3. test(4);
=> (int) 10
4. for(int i =0; i<10; i++) printf("hello %d\n",test(i));

What is the expected output? What do you see instead?
Segmentation fault.
for(int i =0; i<10; i++) printf("hello %d\n",test(10));
works instead.

What version of the product are you using? On what operating system?
ccons r215, osx 10.6.7

Please provide any additional information below.

Original issue reported on code.google.com by david.pi...@gmail.com on 17 May 2011 at 4:04

GoogleCodeExporter commented 9 years ago
This is of course my error!!! (int i = 0....)
Sorry, I was too fast.

Original comment by david.pi...@gmail.com on 18 May 2011 at 8:36

GoogleCodeExporter commented 9 years ago

Original comment by Alexei.Svitkine@gmail.com on 10 Jul 2012 at 4:06