From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 92046 invoked by alias); 14 Sep 2016 04:08:22 -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 92033 invoked by uid 89); 14 Sep 2016 04:08:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.2 spammy= X-HELO: mail-oi0-f51.google.com Received: from mail-oi0-f51.google.com (HELO mail-oi0-f51.google.com) (209.85.218.51) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 14 Sep 2016 04:08:11 +0000 Received: by mail-oi0-f51.google.com with SMTP id q188so3386695oia.3 for ; Tue, 13 Sep 2016 21:08:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=UUAU/1h7AV0I7It4XPoxAInVy35GcA1VyC+3QezsH/o=; b=PRUWv+SzgbI2TP9ltK3mqzmQwMJizsUI0obC3TgD55w5EEJgKD/4yqdBLrunWl9/ae ay4O9VqJTKLfG1EbGhCMsPnr4xyF/Y1hIJRtSJOsctgX/8PkhUlgZ4dNP1IG/oggOADp A/2g8k6NUsjTIQHEqdw5CDT7KsfYpo2VfsZOEgOT4lZfbDzdqqwXJ0qnaCZTy2WMsXus Hkj9UP79DbKk0z//IRDhnC5IQ2M2UYmfBi4dAdyDgKA9vqkvIt5DIDBVB3LBqcvd+Wm/ 0GF1/d1R2OiiVJz3D3M4l++n9P+XpNVsUGuTiFEZexl7KSl4pTc7pWgcHpTj3A7QIx1a OZ7Q== X-Gm-Message-State: AE9vXwP+gwPKC97Kug7G3gEUOzlr4+7PFiBZO+KUFH5c9JT379N73myDxhK5e8ZL59QiHMBGs36mLFVO8MZ7s2lZ X-Received: by 10.157.18.199 with SMTP id g65mr361710otg.182.1473826090001; Tue, 13 Sep 2016 21:08:10 -0700 (PDT) MIME-Version: 1.0 Received: by 10.182.105.169 with HTTP; Tue, 13 Sep 2016 21:07:49 -0700 (PDT) In-Reply-To: <20160910145843.GJ19950@redhat.com> References: <20160910145843.GJ19950@redhat.com> From: Jason Merrill Date: Wed, 14 Sep 2016 05:56:00 -0000 Message-ID: Subject: Re: C/C++ PATCH to implement -Wpointer-compare warning (PR c++/64767) To: Marek Polacek Cc: GCC Patches , Joseph Myers Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2016-09/txt/msg00780.txt.bz2 On Sat, Sep 10, 2016 at 10:58 AM, Marek Polacek wrote: > Spurred by the recent findings, I decided to > implement a warning that warns when a pointer is compared with a zero character > literal (constant), because this isn't likely to be intended. So e.g. > > ptr == L'\0' > > is probably wrong and should've been written as > > ptr[0] == L'\0' > > Jonathan pointed out that this would actually be invalid C++11 since pointer > conversions are only allowed for integer literals, not char literals. Ah, indeed. And if we fix that, we get an error rather than a warning. Maybe let's handle this by wrapping character literals in a redundant NOP_EXPR? Jason