public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "manu at gcc dot gnu.org" <gcc-bugzilla@gcc.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 11:37:00 -0000 [thread overview] Message-ID: <bug-66322-4-hcGxeEGZmn@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-66322-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66322 --- Comment #6 from Manuel López-Ibáñez <manu at gcc dot gnu.org> --- (In reply to Jakub Jelinek from comment #2) > 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 }. Indeed. I wrote: https://gcc.gnu.org/wiki/VerboseDiagnostics#warning:_switch_condition_has_boolean_value_.5B-Wswitch-bool.5D for future reference. I think there will be always "valid" cases that GCC cannot avoid warning, so perhaps it is useful to explain the reasoning behind it and what is the best way to work-around it. (It seems the cast is after all not the best way, converting it to if-else seems better). >From gcc-bugs-return-487504-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Thu May 28 11:54:16 2015 Return-Path: <gcc-bugs-return-487504-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org> Delivered-To: listarch-gcc-bugs@gcc.gnu.org Received: (qmail 59738 invoked by alias); 28 May 2015 11:54:14 -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 59630 invoked by uid 55); 28 May 2015 11:54:09 -0000 From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/65352] array<T,0>::begin()/end() etc. forms a null reference and breaks on clang+ubsan Date: Thu, 28 May 2015 11:54:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 4.9.2 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: redi at gcc dot gnu.org X-Bugzilla-Status: NEW 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: Message-ID: <bug-65352-4-lK6zKKTh8y@http.gcc.gnu.org/bugzilla/> In-Reply-To: <bug-65352-4@http.gcc.gnu.org/bugzilla/> References: <bug-65352-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: 2015-05/txt/msg02344.txt.bz2 Content-length: 875 https://gcc.gnu.org/bugzilla/show_bug.cgi?ide352 --- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> --- Author: redi Date: Thu May 28 11:53:35 2015 New Revision: 223806 URL: https://gcc.gnu.org/viewcvs?rev"3806&root=gcc&view=rev Log: PR libstdc++/65352 * include/std/array (__array_traits::_S_ptr): New function. (array::data): Use _S_ptr to avoid creating invalid reference. * testsuite/23_containers/array/tuple_interface/get_neg.cc: Adjust dg-error line numbers. * testsuite/23_containers/array/tuple_interface/tuple_element_neg.cc: likewise. Modified: trunk/libstdc++-v3/ChangeLog trunk/libstdc++-v3/include/std/array trunk/libstdc++-v3/testsuite/23_containers/array/tuple_interface/get_neg.cc trunk/libstdc++-v3/testsuite/23_containers/array/tuple_interface/tuple_element_neg.cc
next prev parent reply other threads:[~2015-05-28 11:37 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2015-05-28 6:51 [Bug preprocessor/66322] New: " t.artem at mailcity dot com 2015-05-28 8:14 ` [Bug c/66322] " manu at gcc dot gnu.org 2015-05-28 9:29 ` mpolacek at gcc dot gnu.org 2015-05-28 9:38 ` mpolacek at gcc dot gnu.org 2015-05-28 10:31 ` nszabolcs at gmail dot com 2015-05-28 11:37 ` manu at gcc dot gnu.org [this message] 2015-06-22 18:16 ` mpolacek at gcc dot gnu.org 2015-06-29 13:13 ` mpolacek at gcc dot gnu.org 2015-10-22 9:14 ` mpolacek at gcc dot gnu.org 2022-01-11 21:00 ` pinskia at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-66322-4-hcGxeEGZmn@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).