From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 70332 invoked by alias); 5 Sep 2016 15:01:24 -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 70320 invoked by uid 89); 5 Sep 2016 15:01:23 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=H*RU:sk:BAY004-, Hx-spam-relays-external:sk:BAY004-, insane, blandly X-HELO: BAY004-OMC2S9.hotmail.com Received: from bay004-omc2s9.hotmail.com (HELO BAY004-OMC2S9.hotmail.com) (65.54.190.84) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 05 Sep 2016 15:01:13 +0000 Received: from EUR01-HE1-obe.outbound.protection.outlook.com ([65.54.190.123]) by BAY004-OMC2S9.hotmail.com over TLS secured channel with Microsoft SMTPSVC(7.5.7601.23008); Mon, 5 Sep 2016 08:01:12 -0700 Received: from HE1EUR01FT060.eop-EUR01.prod.protection.outlook.com (10.152.0.60) by HE1EUR01HT133.eop-EUR01.prod.protection.outlook.com (10.152.0.216) 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 15:01:10 +0000 Received: from AM4PR0701MB2162.eurprd07.prod.outlook.com (10.152.0.56) 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 15:01:10 +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 15:01:09 +0000 From: Bernd Edlinger To: Marek Polacek CC: Joseph Myers , "gcc-patches@gcc.gnu.org" Subject: Re: C/C++ PATCH for c/77423 (bogus warning with -Wlogical-not-parentheses) Date: Mon, 05 Sep 2016 15:03:00 -0000 Message-ID: References: <20160905120329.GC19950@redhat.com> <20160905142850.GD19950@redhat.com> In-Reply-To: <20160905142850.GD19950@redhat.com> authentication-results: spf=softfail (sender IP is 10.152.0.56) smtp.mailfrom=hotmail.de; redhat.com; dkim=none (message not signed) header.d=none;redhat.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.56 as permitted sender) x-ms-exchange-messagesentrepresentingtype: 1 x-eopattributedmessage: 0 x-microsoft-exchange-diagnostics: 1;HE1EUR01HT133;6:QK6ZBR+7TqPpzv8RWxQFTAQoYroLuogPBc71UW8GE48Lc+KiPnrOzepbgQYciVM99TP8s9FlwSjFoyL0Wil26PgjPwBRqLhF2lXsXGOc+wQTu/7bsYSKo6USuleHtJOXR33FlR9mdOhUX6j45qQV3tJbY11olG3NlEs7I6qcJAadM2nrw7wdD0aKHXjVaqhM6dD9CB8z0ht76Ukq43pTBU7IZSOcfLx2SOGiHoVgFlERZV02c2mTL8gRmjZFgGNJvknVqvqoum+Geb4UJRPT3qlT6SkT8hl/JXmaEWjqBzfid6/y5CtgEDiaoc6V9sFt;5:y2Hgj1N1KjE5AOmZln/E3Y/rPeJQPLNsIIbqTFk+i+Upi4kh2wSeNlyV43G/7viGD3FKZtfeXmN6vAcMb4hlqZYcLbRDmvlISIO+b51KtO7to7IbfsXV6ONzyV/LEJt2feSd1JeuHHURjeqBbwHATg==;24:OpzKNrqGBqf+8AItuNna/IyaovRnuG883RFO7LKn5LHPGydeWvyhPzj5OS1hZU187SUixSCCOF3gHHDm1v2sjCL+ORxQzZ5jEA1QH2VXigQ=;7:vnAlfYtYu+CkhkKCPAkUwp4c4Meix562GRaflB1WyCZ10n93aT0O0Ag1fOXUKfvCPrYBaBIUf3gAT2ZLUh+DU5zD8ca2lpxW9bFdEhmnN5LfmYiio3VIl8QyE2DXwxeDV9pi/tLq61EKEtxcQq1WzUCL2JPMMw/ZqquRj433aZ+T1NadN6Vxr8NzDP0MHEX8bdApJBZ4PXO27EtkumwqYrN7NnHuzoT7xBeNbRNE/KQEErL+rb2S0f7O9eqTc+0U x-forefront-antispam-report: EFV:NLI;SFV:NSPM;SFS:(10019020)(98900003);DIR:OUT;SFP:1102;SCL:1;SRVR:HE1EUR01HT133;H:AM4PR0701MB2162.eurprd07.prod.outlook.com;FPR:;SPF:None;LANG:en; x-ms-office365-filtering-correlation-id: ea438a4d-8401-4854-d26f-08d3d59d77e4 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(1601124038)(1603103081)(1601125047);SRVR:HE1EUR01HT133; x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(432015012)(82015046);SRVR:HE1EUR01HT133;BCL:0;PCL:0;RULEID:;SRVR:HE1EUR01HT133; x-forefront-prvs: 005671E15D spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="Windows-1252" Content-ID: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-originalarrivaltime: 05 Sep 2016 15:01:09.6986 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1EUR01HT133 X-SW-Source: 2016-09/txt/msg00208.txt.bz2 On 09/05/16 16:28, Marek Polacek wrote: > On Mon, Sep 05, 2016 at 02:08:20PM +0000, Bernd Edlinger wrote: >> On 09/05/16 14:03, Marek Polacek wrote: >>> On Fri, Sep 02, 2016 at 03:51:49PM +0000, Bernd Edlinger wrote: >>>> Hi, >>>> >>>> > + r +=3D !a =3D=3D ~b; >>>> > + r +=3D !a =3D=3D ~(int) b; >>>> >>>> I don't understand why ~b should not be warned at -Wall. >>> >>> Yeah, there was an RFE for this but I'm not finding it. >>> >> >> I certainly agree that the warning is compeletely misleading here: >> >> test.c: In function 'f': >> test.c:10:11: warning: logical not is only applied to the left hand side >> of comparison [-Wlogical-not-parentheses] >> r +=3D !a =3D=3D ~b; >> ^~ >> test.c:10:8: note: add parentheses around left hand side expression to >> silence this warning >> r +=3D !a =3D=3D ~b; >> ^~ >> ( ) >> >> this will not fix it, but make it worse. >> I think a better warning would be >> warning: ~ on boolean value, did you mean ! ? > > Could you please open a PR? I'll take care of it. > Done, thanks: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D77490 > Still not sure about other operations. I guess no one would > object to warning on bool1 % bool2, but should we warn for > bool1 + bool2? > Yeah, any % bool is just blandly insane. Please add a warning for that as well. Not totally sure what to do about bool + bool: If it is *not* used in=20 boolean context it's probably OK, but in boolean context why not use | instead? Note: we even optimize unary - in boolean context: see c-family/c-common.c (c_common_truthvalue_conversion): case NEGATE_EXPR: case ABS_EXPR: case FLOAT_EXPR: case EXCESS_PRECISION_EXPR: /* These don't change whether an object is nonzero or zero. */ return c_common_truthvalue_conversion (location, TREE_OPERAND=20 (expr, 0)); I wonder why there is no warning for NEGATE_EXPR and ABS_EXPR. Bernd.