From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22012 invoked by alias); 1 Dec 2008 10:02:48 -0000 Received: (qmail 6556 invoked by uid 48); 1 Dec 2008 10:01:24 -0000 Date: Mon, 01 Dec 2008 10:02:00 -0000 Message-ID: <20081201100124.6554.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug c/38341] Wrong warning comparison of promoted ~unsigned with unsigned In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "rguenth at gcc dot gnu dot org" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2008-12/txt/msg00027.txt.bz2 ------- Comment #1 from rguenth at gcc dot gnu dot org 2008-12-01 10:01 ------- /* Warn if two unsigned values are being compared in a size larger than their original size, and one (and only one) is the result of a `~' operator. This comparison will always fail. Also warn if one operand is a constant, and the constant does not have all bits set that are set in the ~ operand when it is extended. */ note that integer promotion is done on the operand(!) of ~. So u1 == (u8_t)(~u2) is equal to (int)u1 == (int)(u8_t)(~(int)u2) that we do not warn for the first case is because it is optimized to u1 == ~u2 before. Why do you think the warning is incorrect? -- rguenth at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |diagnostic http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38341