[comp.lang.c++] BUG III

pabuhr@water.UUCP (10/11/87)

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"

/* <<cfront 1.2.1 2/16/87>> */
/* < 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 */