From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7371 invoked by alias); 24 Feb 2009 00:40:47 -0000 Received: (qmail 7329 invoked by uid 48); 24 Feb 2009 00:40:28 -0000 Date: Tue, 24 Feb 2009 00:40:00 -0000 Message-ID: <20090224004028.7328.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: "michael dot malone at tait dot co dot nz" 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: 2009-02/txt/msg02064.txt.bz2 ------- Comment #8 from michael dot malone at tait dot co dot nz 2009-02-24 00:40 ------- #ifdef UINT #include #define TYPE uint16_t #else #define TYPE unsigned short int #endif #define VALUE 0xFF int main(void); int main() { TYPE variable_a = ~VALUE; TYPE variable_b = VALUE; TYPE result; #ifdef ASSIGN TYPE tmp = ~variable_a; result = (variable_b == tmp); #else result = (variable_b == (TYPE) ~variable_a); #endif return 0; } Further to John's input, here is a sample program which shows up why this bug is interesting. When one uses a typedef'd type, the promoted comparison warning is displayed. When one does not, it isn't! This is not the case for gcc-4.2.3 -both variants compile without warnings. The compile commands I used were: gcc gcc_bug.c -W -Wall -o bug and gcc gcc_bug.c -W -Wall -DUINT -o bug -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38341