public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/60439] New: No warning for case overflow in switch statement.
@ 2014-03-06  7:06 chengniansun at gmail dot com
  2014-03-13 14:37 ` [Bug c/60439] " mpolacek at gcc dot gnu.org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: chengniansun at gmail dot com @ 2014-03-06  7:06 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60439

            Bug ID: 60439
           Summary: No warning for case overflow in switch statement.
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: chengniansun at gmail dot com

For the switch statement in the function f2, the controlling expression is
either 1 or 0, and the first "case 1111" exceeds the max value. 


$: cat s.c
int f1(char c) {
  switch(c) {
  case 111111: return 1; /*warning here*/
  default: return 0;
  }
}
int f2(char c, char d) {
  switch(c && d) {
  case 1111: return 1; /*no warning here*/
  default: return 0;
  }
}
$: gcc-trunk -c s.c 
s.c: In function ‘f1’:
s.c:3:3: warning: case label value exceeds maximum value for type
   case 111111: return 1; /*warning here*/
   ^
>From gcc-bugs-return-445550-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Thu Mar 06 07:14:31 2014
Return-Path: <gcc-bugs-return-445550-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 16366 invoked by alias); 6 Mar 2014 07:14:31 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 16345 invoked by uid 48); 6 Mar 2014 07:14:28 -0000
From: "pinskia at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/60439] No warning for case overflow in switch statement.
Date: Thu, 06 Mar 2014 07:14: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: pinskia at gcc dot gnu.org
X-Bugzilla-Status: UNCONFIRMED
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: <bug-60439-4-wooFcgLLaG@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-60439-4@http.gcc.gnu.org/bugzilla/>
References: <bug-60439-4@http.gcc.gnu.org/bugzilla/>
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/msg00419.txt.bz2
Content-length: 190

http://gcc.gnu.org/bugzilla/show_bug.cgi?id`439

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Well in C, the type of a && is an int even though the range is 0...1 .


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2014-06-16 12:38 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-06  7:06 [Bug c/60439] New: No warning for case overflow in switch statement chengniansun at gmail dot com
2014-03-13 14:37 ` [Bug c/60439] " mpolacek at gcc dot gnu.org
2014-03-13 18:34 ` chengniansun at gmail dot com
2014-03-13 18:39 ` chengniansun at gmail dot com
2014-03-13 18:45 ` mpolacek at gcc dot gnu.org
2014-03-13 18:49 ` chengniansun at gmail dot com
2014-04-17 18:47 ` mpolacek at gcc dot gnu.org
2014-06-03 17:36 ` mpolacek at gcc dot gnu.org
2014-06-03 17:38 ` mpolacek at gcc dot gnu.org
2014-06-11 17:23 ` gary at intrepid dot com
2014-06-11 17:45 ` mpolacek at gcc dot gnu.org
2014-06-11 17:53 ` gary at intrepid dot com
2014-06-16 12:38 ` mpolacek at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).