From: Maarten B. <maa...@mi...> - 2003-04-02 16:23:42
|
Hello, Just out of curiosity, why would s be destructed if you call exit()? I find it somewhat hard to believe (counter intuitive, even unwanted) that calling exit() from inside maybe a 10 level deep calling sequence would cause all stack based variables to be destructed? Thanks for any insights! Cheers, Maarten. On Tue, 2003-04-01 at 23:36, Geoff Alexander wrote: > > ----- Original Message ----- > From: Jeremy Fitzhardinge > To: Geoff Alexander > Cc: val...@li... > Sent: Tuesday, April 01, 2003 1:31 AM > Subject: Re: [Valgrind-users] "still reachable" memory from > g++'sstd::string > On Mon, 2003-03-31 at 20:47, Geoff Alexander wrote: > > In running valgrind 1.0.4 against a small program of mine, > > valgrind reports "still reachable" memory at exit, both with > > g++ 2.95.2 and gcc 3.2 on SuSE Linux x86 7.1. I've tracked > > the problem down to std::string. Here's a small program > > that illustrates the problem: > > #include <cstdlib> > > #include <string> > > int main(int argc, char* argv[]) > > { > > { > > std::string s; > > s += '0'; > > } > > exit(0); > > } > > What happens if you return 0 rather than exit(0)? I'm not > sure that s will necessarily have been destructed if you use > exit. > J > Thanks for the suggestion. Using return 0 rather than exit(0) didn't > change anything. I verified under gdb that s is being destructed in > both cases. > > Geoff Alexander -- Maarten Ballintijn <maa...@mi...> Massachusetts Institute of Technology |