From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8565 invoked by alias); 13 Mar 2014 18:34:47 -0000 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 Received: (qmail 8531 invoked by uid 48); 13 Mar 2014 18:34:44 -0000 From: "chengniansun at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/60439] No warning for case overflow in switch statement. Date: Thu, 13 Mar 2014 18:34:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 4.9.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: chengniansun at gmail dot com X-Bugzilla-Status: RESOLVED 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: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-03/txt/msg01085.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60439 --- Comment #3 from Chengnian Sun --- (In reply to Marek Polacek from comment #2) > Right. So I think there's nothing much to do. Please reopen if you > strongly disagree. Hi Marek, >>From the perspective of type system, I think no warning is fine. But from the viewpoint of practice, IMHO this should be an overlooked case, as at runtime there is indeed overflow. The reason that I filed this report is not only that Clang emits a warning on this issue (shown as below), but also that Gcc is able to handle the value range of expressions (if I under the report PR60036 correctly). ------------------------------------------------------------------- $: clang-trunk -Wswitch s.c -c s.c:3:8: warning: overflow converting case value to switch condition type (111111 to 7) [-Wswitch] case 111111: return 1; /*warning here*/ ^ s.c:8:3: warning: switch condition has boolean value switch(c && d) { ^ ~~~~~~