From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 78023 invoked by alias); 8 Jan 2016 17:49: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 78008 invoked by uid 89); 8 Jan 2016 17:49:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-spam-relays-external:209.85.192.67, H*RU:209.85.192.67, perfect, turning X-HELO: mail-qg0-f67.google.com Received: from mail-qg0-f67.google.com (HELO mail-qg0-f67.google.com) (209.85.192.67) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Fri, 08 Jan 2016 17:49:20 +0000 Received: by mail-qg0-f67.google.com with SMTP id 94so42648257qgt.1 for ; Fri, 08 Jan 2016 09:49:20 -0800 (PST) X-Received: by 10.140.250.70 with SMTP id v67mr156633006qhc.43.1452275358313; Fri, 08 Jan 2016 09:49:18 -0800 (PST) Received: from [192.168.0.26] (71-212-229-169.hlrn.qwest.net. [71.212.229.169]) by smtp.gmail.com with ESMTPSA id l107sm33516609qge.22.2016.01.08.09.49.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Jan 2016 09:49:17 -0800 (PST) Message-ID: <568FF69B.10803@gmail.com> Date: Fri, 08 Jan 2016 17:49:00 -0000 From: Martin Sebor User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Joseph Myers , Marek Polacek CC: GCC Patches Subject: Re: C PATCH to rectify warning for character types (PR c/23087) References: <20160107171127.GK31604@redhat.com> In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2016-01/txt/msg00441.txt.bz2 On 01/07/2016 02:19 PM, Joseph Myers wrote: > On Thu, 7 Jan 2016, Marek Polacek wrote: > >> This PR points out that we issue a wrong warning message when assigning >> two pointers when one of them is plain char. In that case, the compiler >> currently says that pointer targets differ in signedness. But that is >> not correct; char is a separate type from (un)signed char and is not >> compatible with either. So we should instead say that the pointer types >> are not compatible. >> >> This effectively means that I'm turning a -Wpointer-sign warning into >> a -Wincompatible-pointer-types warning. But -Wincompatible-pointer-types >> is a warning that is enabled by default and -Wpointer-sign is enabled by >> -Wpedantic || -Wall. So with this, we'd be more verbose and would warn >> by default on e.g. "unsigned char *p = "foo";." Not sure if that is >> desirable at this stage, so I'm leaning towards pushing this patch for >> GCC7. > > I don't think it's desirable to raise the warning for this case under > different conditions from the warning for other signedness cases. The > targets do differ in signedness - it's just that the difference is between > "plain" and "signed" or "plain" and "unsigned", not between signed and > unsigned. I'm sorry Joseph but I don't quite follow this argument. Plain char is neither a signed [integer] type nor an unsigned [integer] type, so it can never differ in signedness from any other type. It seems to me that by the interpretation you suggest, converting a signed int* to unsigned long* should be controlled by -Wpointer- sign when int and long have the same representation, and by -Wincompatible-pointer-types otherwise. (Which is not what GCC does.) In my view, Marek's change makes perfect sense because it the most closely reflects the properties of the type. Martin