| View previous topic :: View next topic |
| Author |
Message |
ip4ram@yahoo.com Guest
|
Posted: Wed Jun 30, 2004 12:23 am Post subject: Stack overflow |
|
|
I am quite puzzled by the stack overflow which I am encountering.Here
is the pseudocode
//define stack structure
//function operating on stack
void my_stack_function( function parameters)
{
do required stuff
if(some conditions obeyed)
call my_stack_function(function parameters);
}
//in main()
{
initial conditions;
if(conditions obeyed)
{
call my_stack_function(function parameners);
call a_function_to_pop_contents_of_stack();
}
}
The conditions are so set that my_stack_function is not called
infinite number of times. I get a stack overflow when executing this.I
am not sure if I made any logical error.Does anybody see any silly
logic??
Thanks for your help
Ram
|
|
| Back to top |
|
 |
Leor Zolman Guest
|
Posted: Wed Jun 30, 2004 1:03 am Post subject: Re: Stack overflow |
|
|
On 29 Jun 2004 17:23:50 -0700, [email]ip4ram (AT) yahoo (DOT) com[/email] wrote:
| Quote: | I am quite puzzled by the stack overflow which I am encountering.Here
is the pseudocode
//define stack structure
//function operating on stack
void my_stack_function( function parameters)
{
do required stuff
if(some conditions obeyed)
call my_stack_function(function parameters);
}
//in main()
{
initial conditions;
if(conditions obeyed)
{
call my_stack_function(function parameners);
call a_function_to_pop_contents_of_stack();
}
}
The conditions are so set that my_stack_function is not called
infinite number of times. I get a stack overflow when executing this.I
am not sure if I made any logical error.Does anybody see any silly
logic??
Thanks for your help
Ram
|
Any time you have a stack overflow, suspect runaway recursion. It may not
be infinite recursion (because it does eventually crash with an error
message!) but it is probably effectively infinite. Post your actual code if
you can't figure it out...
-leor
--
Leor Zolman --- BD Software --- www.bdsoft.com
On-Site Training in C/C++, Java, Perl and Unix
C++ users: download BD Software's free STL Error Message Decryptor at:
www.bdsoft.com/tools/stlfilt.html
|
|
| Back to top |
|
 |
JKop Guest
|
Posted: Wed Jun 30, 2004 10:53 am Post subject: Re: Stack overflow |
|
|
posted:
| Quote: | void my_stack_function( function parameters)
{
do required stuff
if(some conditions obeyed)
call my_stack_function(function parameters);
}
|
What's "call"?
-JKop
|
|
| Back to top |
|
 |
David White Guest
|
Posted: Wed Jun 30, 2004 2:01 pm Post subject: Re: Stack overflow |
|
|
<ip4ram (AT) yahoo (DOT) com> wrote
| Quote: | I am quite puzzled by the stack overflow which I am encountering.Here
is the pseudocode
//define stack structure
//function operating on stack
void my_stack_function( function parameters)
{
do required stuff
if(some conditions obeyed)
call my_stack_function(function parameters);
}
//in main()
{
initial conditions;
if(conditions obeyed)
{
call my_stack_function(function parameners);
call a_function_to_pop_contents_of_stack();
}
}
The conditions are so set that my_stack_function is not called
infinite number of times. I get a stack overflow when executing this.I
am not sure if I made any logical error.Does anybody see any silly
logic??
|
No. Real code is needed, not only to see the problem, but to qualify as
on-topic here.
DW
|
|
| Back to top |
|
 |
|