From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 101232 invoked by alias); 28 May 2015 08:14:23 -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 101158 invoked by uid 48); 28 May 2015 08:14:19 -0000 From: "manu at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/66322] Linus Torvalds: -Wswitch-bool produces dubious warnings, fails to notice really bad things Date: Thu, 28 May 2015 08: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: 5.1.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: manu at gcc dot gnu.org 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: cc Message-ID: In-Reply-To: References: 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-SW-Source: 2015-05/txt/msg02318.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D66322 Manuel L=C3=B3pez-Ib=C3=A1=C3=B1ez changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |manu at gcc dot gnu.org --- Comment #1 from Manuel L=C3=B3pez-Ib=C3=A1=C3=B1ez --- I think originally, the warning was supposed to catch things like switch (n && MASK) {} or even using the wrong variable in the switch(). Of course, it could be smarter and avoid warning about the specific case 'switch(bool) {case true: case false:}', which is what Linus says here: https://lkml.org/lkml/2015/5/27/933 If only GCC had 1/100th of the developers of the Linux kernel...=20 The manual and the warning text could also say explicitly the reason for warning (something like "often indicates a typo") >>From gcc-bugs-return-487479-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Thu May 28 08:29:24 2015 Return-Path: Delivered-To: listarch-gcc-bugs@gcc.gnu.org Received: (qmail 32081 invoked by alias); 28 May 2015 08:29:24 -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 Delivered-To: mailing list gcc-bugs@gcc.gnu.org Received: (qmail 32042 invoked by uid 48); 28 May 2015 08:29:20 -0000 From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/66322] Linus Torvalds: -Wswitch-bool produces dubious warnings, fails to notice really bad things Date: Thu, 28 May 2015 08:29: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: 5.1.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org 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: cc 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: 2015-05/txt/msg02319.txt.bz2 Content-length: 588 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66322 Jakub Jelinek changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #2 from Jakub Jelinek --- Well, using switch on bool is always weird, one really should use if for that. If you want fallthrough, then just use if (cond) { first } second, if without fallthrough, then if (cond) { first } else { second }.