S
Syncnister
Hello everyone,
I have found some old c++ code with function defined as returning
boolean. The thing is that doesn't have any return statement at the
end. Looking at how the function is being used, suggesting that it is
expected to return true by default.
bool MyFunction()
{
if (sometest)
{
return false;
}
somecode;
somecode;
// missing return
}
My compiler is the latest GCC / G++ and the target system is HPUX. My
testing environment (where I found the problem) is Cygwin. I suspect
that in HPUX I'm getting return value true as default, but on cygwin
I'm getting false.
I am trying to explain why this happen (to my self) and to justify
adding return false before the function exit. Appreciate any thought.
I have found some old c++ code with function defined as returning
boolean. The thing is that doesn't have any return statement at the
end. Looking at how the function is being used, suggesting that it is
expected to return true by default.
bool MyFunction()
{
if (sometest)
{
return false;
}
somecode;
somecode;
// missing return
}
My compiler is the latest GCC / G++ and the target system is HPUX. My
testing environment (where I found the problem) is Cygwin. I suspect
that in HPUX I'm getting return value true as default, but on cygwin
I'm getting false.
I am trying to explain why this happen (to my self) and to justify
adding return false before the function exit. Appreciate any thought.