Boolean equality (C++/Fortran)
David Lecomber
david@streamline-computing.com
Fri Sep 3 14:53:00 GMT 2004
In valarith.c:value_binop, where v1 and v2 have been established to be
values of type bool, we have:
case BINOP_EQUAL:
v = v1 == v2;
break;
case BINOP_NOTEQUAL:
v = v1 != v2;
break;
Isn't this wrong? If you are mixing your compilers, then, at least for
Fortran, the actual value of true can vary (1 or -1 I have so far
seen). For C++ this is less likely to happen, and so far as I can tell
changing the above would not harm anything.
Does anyone have any comments on replacing the above with:
case BINOP_EQUAL:
v = !((!v1 && v2) || (v1 && !v2));
break;
case BINOP_NOTEQUAL:
v = (!v1 && v2) || (v1 && !v2);
break;
d.
More information about the Gdb
mailing list