From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 90338 invoked by alias); 7 Mar 2019 23:40:14 -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 90327 invoked by uid 89); 7 Mar 2019 23:40:14 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham version=3.3.1 spammy=promoted, HX-Languages-Length:450, throws, H*F:D*com.au X-HELO: susu.bendor.com.au Received: from susu.bendor.com.au (HELO susu.bendor.com.au) (203.16.199.2) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 07 Mar 2019 23:40:11 +0000 Received: from linux-o3yw (unknown [130.56.34.198]) by susu.bendor.com.au (Postfix) with ESMTPSA id 8D31556004D for ; Fri, 8 Mar 2019 10:40:07 +1100 (EST) Date: Thu, 07 Mar 2019 23:40:00 -0000 From: Zoltan Kocsi To: gcc@gcc.gnu.org Subject: Signed-unsigned comparison question Message-ID: <20190308104006.727e495f@linux-o3yw> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2019-03/txt/msg00049.txt.bz2 Gcc 8.2.0 (arm-none-eabi) throws a warning on the following construct: uint32_t a; uint16_t b; if ( a > b ) ... compaining that a signed integer is compared against an unsigned. Of course, it is correct, as 'b' was promoted to int. But shouldn't it be smart enough to know that (int) b is restricted to the range of [0,65535] which it can safely compare against the range of [0,0xffffffffu]? Thanks, Zoltan