J
John Black
Hi,
I wonder what is the difference between ending the main() with and
without exit(0)?
My code is like this flow,
class ClassA{
ClassB* cb;
int toExit();
public:
~ClassA();
... constructors and all other API...
}
ClassA::~ClassA(){
this->toExit();
}
ClassA::toExit(){
if (cb != NULL){
delete cb;
cb = NULL;
}
}
int main(int argc, char** argv){
ClassA ca;
... some operation ...
return 0;
}
Then the program exits with a core dump, in debugger I can see that
the core dump comes from "}" after "return 0;" in main() and "delete cb"
in ClassA::toExit().
In purify it says some FMR, Free Memory Read errors.
Then I replace "return 0" with "exit(0)" in main(), everything is
fine: there is no core dump and purify FMR errors are gone!
What's the trick here?
Thanks.
I wonder what is the difference between ending the main() with and
without exit(0)?
My code is like this flow,
class ClassA{
ClassB* cb;
int toExit();
public:
~ClassA();
... constructors and all other API...
}
ClassA::~ClassA(){
this->toExit();
}
ClassA::toExit(){
if (cb != NULL){
delete cb;
cb = NULL;
}
}
int main(int argc, char** argv){
ClassA ca;
... some operation ...
return 0;
}
Then the program exits with a core dump, in debugger I can see that
the core dump comes from "}" after "return 0;" in main() and "delete cb"
in ClassA::toExit().
In purify it says some FMR, Free Memory Read errors.
Then I replace "return 0" with "exit(0)" in main(), everything is
fine: there is no core dump and purify FMR errors are gone!
What's the trick here?
Thanks.