R
rolo
Im trying to do a recursive algoritm and debug it. My problem is that I got
segfault if I run it withous optimizing it with the compiler, since I want
to debug it. If I use a smaller number it runs ok, but im interested on
bigger numbers.
Can anyone help me out and explain why this happens?
heres a sample code: (it doesn't matter if I use template or not, I got the
same results)
If I optimize it with -O3 or -O2 the program runs fine and returns the
expected 0.
#include <iostream>
using namespace std;
template <class T>
inline T one_less(T tmp){
if(tmp > 0) return one_less(tmp - 1);
else return 0;
}//one_less(T tmp){
int main(void){
unsigned long int tmp = 100000;
cout << one_less(tmp) << endl;
cin.get();
return 0;
}//main(void){
~ Let us linux ~
segfault if I run it withous optimizing it with the compiler, since I want
to debug it. If I use a smaller number it runs ok, but im interested on
bigger numbers.
Can anyone help me out and explain why this happens?
heres a sample code: (it doesn't matter if I use template or not, I got the
same results)
If I optimize it with -O3 or -O2 the program runs fine and returns the
expected 0.
#include <iostream>
using namespace std;
template <class T>
inline T one_less(T tmp){
if(tmp > 0) return one_less(tmp - 1);
else return 0;
}//one_less(T tmp){
int main(void){
unsigned long int tmp = 100000;
cout << one_less(tmp) << endl;
cin.get();
return 0;
}//main(void){
~ Let us linux ~