public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
From: Jim Blandy <jimb@redhat.com>
To: David Lecomber <david@streamline-computing.com>
Cc: gdb@sources.redhat.com
Subject: Re: Boolean equality (C++/Fortran)
Date: Tue, 07 Sep 2004 17:26:00 -0000	[thread overview]
Message-ID: <vt2isaqdm9v.fsf@zenia.home> (raw)
In-Reply-To: <1094224351.31231.59.camel@cpc4-oxfd5-5-0-cust12.oxfd.cable.ntl.com>

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;

      reply	other threads:[~2004-09-07 17:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-09-03 14:53 David Lecomber
2004-09-07 17:26 ` Jim Blandy [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=vt2isaqdm9v.fsf@zenia.home \
    --to=jimb@redhat.com \
    --cc=david@streamline-computing.com \
    --cc=gdb@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).