From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6930 invoked by alias); 20 Feb 2018 15:43:44 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 6590 invoked by uid 89); 20 Feb 2018 15:43:44 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy= X-HELO: mail-wr0-f170.google.com Received: from mail-wr0-f170.google.com (HELO mail-wr0-f170.google.com) (209.85.128.170) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 20 Feb 2018 15:43:42 +0000 Received: by mail-wr0-f170.google.com with SMTP id u15so15684272wrg.3 for ; Tue, 20 Feb 2018 07:43:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=t4WMEz7F5JJcTQnISE6s1eP/+BPV1J2kJdVTlpYnmT0=; b=TZH+4EuSMW6tItPWdd+sDLAEj5fK1zRIMiB48SGjTUlB3HBOZV/azrCfWs1SQBqY3J OOhjXyRrduy5SDlblViWFRihybZARQ6ag8jfkykyIYh7v3VilczZ2ae9vfyfRFM1n/KL hPDYjytaCQVfHlyrrDfuMzy23OuwVQQJTiAJz847p4mMNDAlLG99mJw5s4NoLHt5y+d8 /o6G3kD5T0EvpoYMufvivBiAizvOlzslsUwOS1hFArPsK+J7TcChEhE+Vz6s5daWp7NX sci2ZLTKBL2vB+IkpOxzBooL5FSvBN6SUKQwbcxG8ZtOaHlVeoJBGb2wO9aWsgvELCy5 gAOA== X-Gm-Message-State: APf1xPBdVVL3frhEw7PD1yUs9G8dxoFyceebou+1idXkxPW3wMukE4hf Vf8lzLJb15bfXnBZ65jTmzD+7A== X-Google-Smtp-Source: AH8x227xyGZOnFjU3TB9DQAEtw6L1GSx7GACpBodLGbwvmi7LHg9cJu2oT1lMnXgWhteXHTLsf9zEw== X-Received: by 10.28.238.73 with SMTP id m70mr546137wmh.74.1519141420698; Tue, 20 Feb 2018 07:43:40 -0800 (PST) Received: from [192.168.77.22] (val06-1-88-182-161-34.fbx.proxad.net. [88.182.161.34]) by smtp.gmail.com with ESMTPSA id f23sm6005986wrf.77.2018.02.20.07.43.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Feb 2018 07:43:39 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 11.2 \(3445.5.20\)) Subject: Re: sign-compare warning for short and char From: Christophe de Dinechin In-Reply-To: Date: Tue, 20 Feb 2018 15:43:00 -0000 Cc: "gcc@gcc.gnu.org" Content-Transfer-Encoding: quoted-printable Message-Id: <1FE711F4-D99F-47DB-8434-DFB7C96D82E8@redhat.com> References: <50F32C36-4EE5-4375-BAC6-46FCCECE1571@redhat.com> To: Jonathan Wakely X-SW-Source: 2018-02/txt/msg00156.txt.bz2 > On 20 Feb 2018, at 16:15, Jonathan Wakely wrote: >=20 > This question belongs on the gcc-help list really. I posted here because I saw it as a possible diagnostic bug / limitation. D= o such things go to gcc-help? Or is it that you thought I was asking for th= e correct option? > On 20 February 2018 at 14:44, Christophe de Dinechin > wrote: >> I wonder why -Wsign-compare only warns when there is no int promotion? >=20 > I suspect the correct-but-not-helpful answer is that after integer > promotion the operands have the same type, and so there's no > comparison between signed and unsigned types. That=E2=80=99s an implementation explanation, not a rationale, right? > But the compiler could make the warning apply *before* doing integer > promotion, to diagnose this case. That is what I am thinking, but I was wondering if there was not some ratio= nale making this a bad idea.