[net.lang.c++] C++ Bug and Fix

vjm@ius2.cs.cmu.edu (Victor Milenkovic) (07/24/86)

Version 1.0 of the C++ translator does not correctly evaluate constant
expressions involving the logical AND operator.  For example,

	int I = 0 && 1;

translates to,

	int I = 66;

The way to fix this problem (supplied to me by Bjarne Stroustrup) is to
insert a missing case statement.  In source file expr2.c, the second switch
in expr::eval() is missing ``case ANDAND:''.  The corrected portion of the
code should appear as follows:

	case AND:	return i1&i2;
 	case ANDAND:	return i1&&i2;	// This case was missing.
	case OR:	return i1|i2;

According to Bjarne, Version 1.1 also has this problem.

Victor Milenkovic		vjm@ius2.cs.cmu.edu
Computer Science
Carnegie Mellon
Pittsburgh, PA  15213