I didn't free all variables allocated with new because I thought that the program termination woud free them for me. Obviously that could cause my problem. As I am rewriting a c program, I am adding c++ code step by step into my source code. c and c++ are mixed into my code. I read somewhere that I could get conflict. Is it right?
Maurizio Loreti a écrit : > "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > > > I am currently rewriting a c program in c++. I work under LINUX 2.6 > > (DEBIAN). Sometimes I get a segmentation fault when I use "new". Could > > it be because of the compiler "g++". There are still some c functions > > like printf or open. Could it be the cause of my problem? > > as long as 1) all variables allocated with new are freed once and only > once with delete; 2) all varables allocated with new [] are freed once > and only once with delete []; 3) you don't shoot yourself in the foot > with copy-ctors or assignment operators that do not handle correctly > pointers allocated with new or new []; 4) there is nothing corrupting > the arena like you writing in the wrong address (array index out of > range etc.) --- the use of new should be safe and do not cause any > segmentation fault. > > -- > Maurizio Loreti http://www.pd.infn.it/~loreti/mlo.html > Dept. of Physics, Univ. of Padova, Italy ROT13: [EMAIL PROTECTED] _______________________________________________ help-gplusplus mailing list help-gplusplus@gnu.org http://lists.gnu.org/mailman/listinfo/help-gplusplus