This is the mail archive of the
gdb@sources.redhat.com
mailing list for the GDB project.
Boolean equality (C++/Fortran)
- From: David Lecomber <david at streamline-computing dot com>
- To: gdb at sources dot redhat dot com
- Date: Fri, 03 Sep 2004 16:12:31 +0100
- Subject: Boolean equality (C++/Fortran)
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.