* Boolean equality (C++/Fortran)
@ 2004-09-03 14:53 David Lecomber
2004-09-07 17:26 ` Jim Blandy
0 siblings, 1 reply; 2+ messages in thread
From: David Lecomber @ 2004-09-03 14:53 UTC (permalink / raw)
To: gdb
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.
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Boolean equality (C++/Fortran)
2004-09-03 14:53 Boolean equality (C++/Fortran) David Lecomber
@ 2004-09-07 17:26 ` Jim Blandy
0 siblings, 0 replies; 2+ messages in thread
From: Jim Blandy @ 2004-09-07 17:26 UTC (permalink / raw)
To: David Lecomber; +Cc: gdb
David Lecomber <david@streamline-computing.com> writes:
> 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;
The general idea looks right. But how about:
> case BINOP_EQUAL:
> v = !v1 == !v2;
> break;
>
> case BINOP_NOTEQUAL:
> v = !v1 != !v2;
> break;
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2004-09-07 17:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-09-03 14:53 Boolean equality (C++/Fortran) David Lecomber
2004-09-07 17:26 ` Jim Blandy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).