From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io1-xd2b.google.com (mail-io1-xd2b.google.com [IPv6:2607:f8b0:4864:20::d2b]) by sourceware.org (Postfix) with ESMTPS id E212C3857012 for ; Sun, 3 Jan 2021 18:53:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org E212C3857012 Received: by mail-io1-xd2b.google.com with SMTP id m23so23149093ioy.2 for ; Sun, 03 Jan 2021 10:53:46 -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:from:date:message-id:subject:to :content-transfer-encoding; bh=C/Qy+rAUOcVgjrsjn1l65yZrQF1rzmga6Ke294YqNRM=; b=VFUExdRVCYQITeU+aChRoOd1qpLelZdIKQS92dSGi3BzJgY/zckbReC8ETRE0wbhT4 BbXXjBjf07UEq22FMYhQ+F6k8kdDRtFw/W46P21QMe9XBjOBXi+aJsT2As0DfLggnL2n DfmXzlHT6fUulbf+bY3DpQtjB6UbqMKTqy8ucVFX6JytS2dsGJaIskAc3ZnszTjL1e0b /0xiEWiJWmmg10ZDo/ITYAnvvWu+6teqiqy5JB7nQsQiZ4gIEJ7qaxARM+Lo6oOleK5u yjOaFDZAzLSQ8b/r8XaaUx7mF13uNpVcbA8s4lvgSfSSfJ4QstxKfgePNJg3wYtOtB5f 4qqA== X-Gm-Message-State: AOAM5314yWVPXdUsTkr6c6iEUXrOcYiUiqeQMJahwKpZjWklWY0GMJW3 rnZnPuGt9OXZ9z/bjagMcUAJH+jaNz5vBVsoshAk9HAtLb8= X-Google-Smtp-Source: ABdhPJyJ2yheSFPI0mwrCIzD7exZz8ngLLpbCD83npsQhKdq15LjcSuQ3XCKZEBdtvo/iMF5elUv/CV0iZY0G+nSQI4= X-Received: by 2002:a05:6602:150b:: with SMTP id g11mr56512103iow.88.1609700026107; Sun, 03 Jan 2021 10:53:46 -0800 (PST) MIME-Version: 1.0 From: William Roberts Date: Sun, 3 Jan 2021 12:53:35 -0600 Message-ID: Subject: Questions on -Wtype-limits To: gcc-help@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-help@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-help mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 Jan 2021 18:53:48 -0000 When I compile the below program, I expect the -Wtype-limits warning to be displayed for all 4 if conditions, but I only get uint8_t and uint16_t conditions, why? #include #include int main(int argc, char *argv[]) { (void)argv; uint8_t i8 =3D (uint8_t) argc; uint16_t i16 =3D (uint16_t) argc; uint32_t i32 =3D (uint32_t) argc; uint64_t i64 =3D (uint64_t) argc; if (i8 > UINT8_MAX) { return 8; } if (i16 > UINT16_MAX) { return 16; } if (i32 > UINT32_MAX) { return 32; } if (i64 > UINT64_MAX) { return 64; } return 0; } gcc -Wall -Wextra -o go a.c a.c: In function =E2=80=98main=E2=80=99: a.c:13:9: warning: comparison is always false due to limited range of data type [-Wtype-limits] 13 | if (i8 > UINT8_MAX) { | ^ a.c:17:10: warning: comparison is always false due to limited range of data type [-Wtype-limits] 17 | if (i16 > UINT16_MAX) { gcc --version gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0 Copyright (C) 2019 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Thanks, Bill