From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 76EB43851C22; Fri, 15 May 2020 09:25:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 76EB43851C22 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1589534718; bh=7mpAHHtZCH6txG1YB0h5L71a27Z1Mer/4bOYlxzlh6M=; h=From:To:Subject:Date:From; b=JIzyM24WPRp3sGZNS/oPFV6sykfEucaCKY/b3tol2UjgV34saHhBC00E9O/mzM7BZ CEE6+ckTgmJYJNH1OHvWOnS/1+2yBaUO6liMKehNyeIlXSAyf4sq8EoHleA592jwsQ 5vAtAc5lG6zBg/4yPj9Kf/S/nGFm90Eypf9mvusE= From: "eyalroz at technion dot ac.il" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/95148] New: -Wtype-limits always-false warning triggered despite comparison being avoided Date: Fri, 15 May 2020 09:25:18 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 10.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: eyalroz at technion dot ac.il X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 May 2020 09:25:18 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D95148 Bug ID: 95148 Summary: -Wtype-limits always-false warning triggered despite comparison being avoided Product: gcc Version: 10.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: eyalroz at technion dot ac.il Target Milestone: --- Consider the following program: #include int main() { unsigned x { 5 }; return (std::is_signed::value and (x < 0)) ? 1 : 0; } when compiling it with GCC versions 11.0 20200511, 10.1, 9.2.1, 8.3.0, I get the warning: a.cpp:5:52: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits] I should not be getting this warning, because when x is unsigned, the comparison is never performed, due to the short-circuit semantics of `and`. This can be easily determined by the compiler - and probably is. No less importantly, the author of such a line in a program clearly specified his/h= er intent here with this check.=20 clang doesn't seem to issue a warn inf does come to pass.=