Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!pabuhr From: pabuhr@water.UUCP Newsgroups: comp.lang.c++ Subject: BUG III Message-ID: <1164@water.waterloo.edu> Date: Sun, 11-Oct-87 08:04:52 EDT Article-I.D.: water.1164 Posted: Sun Oct 11 08:04:52 1987 Date-Received: Mon, 12-Oct-87 20:43:52 EDT Reply-To: pabuhr@water.UUCP () Distribution: world Organization: U. of Waterloo, Ontario Lines: 97 This bug took me another 4 hours to find. The conditional expression in the while loop requires the creation of 2 temporaries of type string. This is done properly. However, only the temporary on the right hand side of the relational operator is subsequently freed. This only seems to happen in a relational expression. All the temporaries in complex arithmetic expressions seem to be handled properly. Is it possible that we are using an old version of C++? I find it *VERY* difficult to believe that this problem has not appeared before now as it is a rather fundemental bug. ======================= class string { int *i; public: string(); string(string &); // string x = string ~string() { delete i; }; inline friend int operator!=(string &, string &); // != string rtn(); }; main() { string left, right; while ( left.rtn() != right.rtn() ) {} } =============================== #line 1 "bug1.cc" /* <> */ /* < bug1.cc */ char *_new(); char _delete(); char *_vec_new(); char _vec_delete(); #line 1 "bug1.cc" struct string { /* sizeof string == 4 */ #line 2 "bug1.cc" int *_string_i ; }; #line 4 "bug1.cc" /* overload _ctor: */ struct string *_string__ctorF_ (); struct string *_string__ctorFRCstring___ (); #line 9 "bug1.cc" struct string _string_rtn (); #line 8 "bug1.cc" static int _neFRCstring__RCstring___ (); #line 12 "bug1.cc" int main (){ _main(); { #line 13 "bug1.cc" struct string _au1_left ; #line 13 "bug1.cc" struct string _au1_right ; #line 13 "bug1.cc" _string__ctorF_ ( & _au1_left ) ; #line 13 "bug1.cc" _string__ctorF_ ( & _au1_right ) ; #line 15 "bug1.cc" { #line 16 "bug1.cc" struct string _au0__R1 ; #line 16 "bug1.cc" struct string _au0__R2 ; #line 16 "bug1.cc" int _au0__Q3 ; #line 15 "bug1.cc" while (( (_au0__Q3 = (((int )_neFRCstring__RCstring___ ( (struct string *)( _string_rtn ( & _au1_left , & _au0__R1 ) , (& #line 15 "bug1.cc" _au0__R1 )) , (struct string *)( _string_rtn ( & _au1_right , & _au0__R2 ) , (& _au0__R2 )) ) ))), #line 15 "bug1.cc" ( ( (( _delete ( (char *)(& _au0__R2 )-> _string_i ) , (0 )) )) , _au0__Q3 ) ) <==== where is the other delete for _au0_R1?!!!! #line 15 "bug1.cc" ){ } #line 13 "bug1.cc" ( (( _delete ( (char *)(& _au1_right )-> _string_i ) , (0 )) )) ; #line 13 "bug1.cc" ( (( _delete ( (char *)(& _au1_left )-> _string_i ) , (0 )) )) ; } } }; /* the end */