From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 38087 invoked by alias); 23 Apr 2015 17:19:02 -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 38048 invoked by uid 48); 23 Apr 2015 17:18:58 -0000 From: "ktkachov at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/65864] New: Consider emitting -Wswitch-bool less aggressively? Date: Thu, 23 Apr 2015 17:19:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 6.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: enhancement X-Bugzilla-Who: ktkachov 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: bug_id short_desc product version bug_status keywords bug_severity priority component assigned_to reporter cc Message-ID: 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-04/txt/msg02051.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65864 Bug ID: 65864 Summary: Consider emitting -Wswitch-bool less aggressively? Product: gcc Version: 6.0 Status: UNCONFIRMED Keywords: diagnostic Severity: enhancement Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: ktkachov at gcc dot gnu.org CC: mpolacek at gcc dot gnu.org Consider the following function from the linux kernel (fs/nfs/nfs4proc.c): int nfs4_proc_get_rootfh(struct nfs_server *server, struct nfs_fh *fhandle, struct nfs_fsinfo *info, bool auth_probe) { int status; switch (auth_probe) { case false: status = nfs4_lookup_root(server, fhandle, info); if (status != -NFS4ERR_WRONGSEC) break; default: status = nfs4_do_find_root_sec(server, fhandle, info); } if (status == 0) status = nfs4_server_capabilities(server, fhandle); if (status == 0) status = nfs4_do_fsinfo(server, fhandle, info); return nfs4_map_errors(status); } The kernel guys have reported that the new -Wswitch-bool warns on this code and, while ugly, it was a deliberate decision to write it that way (they make 'creative' use of the fall-through in the switch). I wonder whether it makes sense to restrict the -Wswitch-bool warning to the cases where the switch condition becomes a boolean from a complex expression (i.e. a && 0xff, instead of the probably intended a & 0xff) and not warn when the switch variable is a simple boolean var. what do you think?