From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 37370 invoked by alias); 5 Sep 2016 17:01:07 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 37361 invoked by uid 89); 5 Sep 2016 17:01:06 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=justified X-HELO: COL004-OMC1S19.hotmail.com Received: from col004-omc1s19.hotmail.com (HELO COL004-OMC1S19.hotmail.com) (65.55.34.29) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 05 Sep 2016 17:01:05 +0000 Received: from EUR01-VE1-obe.outbound.protection.outlook.com ([65.55.34.9]) by COL004-OMC1S19.hotmail.com over TLS secured channel with Microsoft SMTPSVC(7.5.7601.23008); Mon, 5 Sep 2016 10:01:04 -0700 Received: from HE1EUR01FT060.eop-EUR01.prod.protection.outlook.com (10.152.0.54) by HE1EUR01HT192.eop-EUR01.prod.protection.outlook.com (10.152.1.119) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.587.6; Mon, 5 Sep 2016 17:00:57 +0000 Received: from AM4PR0701MB2162.eurprd07.prod.outlook.com (10.152.0.58) by HE1EUR01FT060.mail.protection.outlook.com (10.152.0.249) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.587.6 via Frontend Transport; Mon, 5 Sep 2016 17:00:56 +0000 Received: from AM4PR0701MB2162.eurprd07.prod.outlook.com ([10.167.132.147]) by AM4PR0701MB2162.eurprd07.prod.outlook.com ([10.167.132.147]) with mapi id 15.01.0599.016; Mon, 5 Sep 2016 17:00:56 +0000 From: Bernd Edlinger To: Joseph Myers , Marek Polacek CC: "gcc-patches@gcc.gnu.org" Subject: Re: C/C++ PATCH for c/77423 (bogus warning with -Wlogical-not-parentheses) Date: Mon, 05 Sep 2016 17:03:00 -0000 Message-ID: References: <20160905120329.GC19950@redhat.com> <20160905142850.GD19950@redhat.com> In-Reply-To: authentication-results: spf=softfail (sender IP is 10.152.0.58) smtp.mailfrom=hotmail.de; codesourcery.com; dkim=none (message not signed) header.d=none;codesourcery.com; dmarc=none action=none header.from=hotmail.de; received-spf: SoftFail (protection.outlook.com: domain of transitioning hotmail.de discourages use of 10.152.0.58 as permitted sender) x-ms-exchange-messagesentrepresentingtype: 1 x-eopattributedmessage: 0 x-microsoft-exchange-diagnostics: 1;HE1EUR01HT192;6:6G0mKB1rue3H74AO8wz/o0CjfsQw25j06Ldaukc20W+wENoXx/9MzU0eIszm+CGpog682587psJe3BncJYl6l5BzsmpS+ft5CnlDoDmKbiZoQ7Sh10v0xURYQB1Sh5VTFNr0jyryCKQYAW40aN3rKKCywI+ITUvtjWZ2P1m4eQJ37bv7u84as/3gHzEl+0Gcausyk3ESICdR8EvwHjAk7K46NHv225nZb4nUFaxaiXgJZdIugkfbCZUNW6yss9eA1Stx+ab3shaJY8NEdaKDXRG6AYa7/prIKzERRSIyhtNBoGx8TbKP+upxjGBa3h1p;5:aHo8L5bIbXggXTZ0yoR137CvfRt5eOhPTBqk5u51DYazQ9TT2v8y/FAJQhlBYBwEeIxiUwhxrLcj4NvYDYlAye37DeSvfaYxjTNW7kWCwYaFZs5WonRiwijOk7aErKKOta+4wB8zZnNJ3CafN4YA2w==;24:3UrBzV8TYC7m4XKE8aZm7gY6aVaEk2/ywJwoecclsllpAwVmW2+WtjwNmdYfmlh+4SaJWSktmh9BUMUWssgIWuQ3K2YWItq4SDKEL1F0g3U=;7:/RJ1CaNeuOdywtKbdZGBz8ocNOGxeOisgyiSrvh0S7FKWD6PDYQyM2wL1uP23SBJAiaPdo5OJo7NKrXnlFFi7ov+dIRLS5wIEyAZq3VWDCeELw/HrpVsWrcaAAChD0R826q++J8BaKP2J4ZzMIeXzYKdQu/m1dk5gd0pF3HGTqyXenVRg5Q29+ifKxVhJjzshyg8TOt3xz8QkqHavAjyoJFuVkAIMKLxDSigQgfBNZYAY/IMCkwLrNWNNwwEO2ek x-forefront-antispam-report: EFV:NLI;SFV:NSPM;SFS:(10019020)(98900003);DIR:OUT;SFP:1102;SCL:1;SRVR:HE1EUR01HT192;H:AM4PR0701MB2162.eurprd07.prod.outlook.com;FPR:;SPF:None;LANG:en; x-ms-office365-filtering-correlation-id: 8da5e612-89bd-498a-7e8d-08d3d5ae33c2 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(1601124038)(1603103081)(1601125047);SRVR:HE1EUR01HT192; x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(432015012)(82015046);SRVR:HE1EUR01HT192;BCL:0;PCL:0;RULEID:;SRVR:HE1EUR01HT192; x-forefront-prvs: 005671E15D spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="Windows-1252" Content-ID: <6591468AEF8DE34BAB56442E899FCC61@eurprd07.prod.outlook.com> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-originalarrivaltime: 05 Sep 2016 17:00:56.6628 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1EUR01HT192 X-SW-Source: 2016-09/txt/msg00225.txt.bz2 On 09/05/16 18:45, Joseph Myers wrote: > On Mon, 5 Sep 2016, Marek Polacek wrote: > >> Still not sure about other operations. I guess no one would >> object to warning on bool1 % bool2, but should we warn for >> bool1 + bool2? > > I think boolean addition (with the result interpreted as an integer, not > converted back to boolean) is perfectly reasonable - counting the number > of flags that are true, for example (say if there are several conditions > and it's an error for more than one of them to hold - of course that would > be bool1 + bool2 + bool3 + bool4, etc.). > Yes, that's what I had in mind too. I think I even remember having seen code like this, which is OK as long as the result is stored in an integer variable. But "if (bool1 + bool2)" should be written as "if (bool1 | bool2)", and "if (bool1 * bool2)" should be written as "if (bool1 & bool2)". I think a warning for boolean + and * suggesting to use | and & is justified for clarity. Bernd.