From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2160 invoked by alias); 7 Sep 2004 17:26:11 -0000 Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sources.redhat.com Received: (qmail 2150 invoked from network); 7 Sep 2004 17:26:10 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org with SMTP; 7 Sep 2004 17:26:10 -0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.10/8.12.10) with ESMTP id i87HQAS0020755 for ; Tue, 7 Sep 2004 13:26:10 -0400 Received: from zenia.home.redhat.com (porkchop.devel.redhat.com [172.16.58.2]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id i87HQ8323935; Tue, 7 Sep 2004 13:26:09 -0400 To: David Lecomber Cc: gdb@sources.redhat.com Subject: Re: Boolean equality (C++/Fortran) References: <1094224351.31231.59.camel@cpc4-oxfd5-5-0-cust12.oxfd.cable.ntl.com> From: Jim Blandy Date: Tue, 07 Sep 2004 17:26:00 -0000 In-Reply-To: <1094224351.31231.59.camel@cpc4-oxfd5-5-0-cust12.oxfd.cable.ntl.com> Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2004-09/txt/msg00059.txt.bz2 David Lecomber 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;