public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "zhaoweiliew at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/25689] missed diagnostic about assignment used as truth value. Date: Wed, 09 Feb 2022 17:24:12 +0000 [thread overview] Message-ID: <bug-25689-4-HDzlKV51TB@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-25689-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=25689 --- Comment #3 from Zhao Wei Liew <zhaoweiliew at gmail dot com> --- Created attachment 52395 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52395&action=edit Test patch (seeking feedback) Hi! I wrote a small patch to fix this issue, but I think that it has much room for improvement, though I'm not very sure how. Could anyone take a look and give me feedback on how I could improve the patch? Here's an example code snippet. I've commented the expected and actual diagnostic results beside the lines of code. struct A { A& operator=(int); operator bool(); }; void f(A a, A b) { if (a = 0); // GCC warns after patch (correct) if (a.operator=(0)) {} // GCC warns after patch (incorrect, but doesn't sound like a major issue) if (a = b) {} // GCC does not warn before & after patch (incorrect) } Specifically, there are 2 issues: 1. GCC warns for `if (a.operator=(0))` 2. GCC does not warn for `if (a = b)` where the default copy/move assignment operator is used. Thanks!
next prev parent reply other threads:[~2022-02-09 17:24 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top [not found] <bug-25689-4@http.gcc.gnu.org/bugzilla/> 2021-08-10 0:44 ` pinskia at gcc dot gnu.org 2022-02-09 17:24 ` zhaoweiliew at gmail dot com [this message] 2022-04-29 2:59 ` cvs-commit at gcc dot gnu.org 2022-07-22 13:54 ` ppalka at gcc dot gnu.org 2006-01-06 9:45 [Bug c++/25689] New: " pluto at agmk dot net 2006-01-06 12:32 ` [Bug c++/25689] " pinskia at gcc dot gnu dot 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-25689-4-HDzlKV51TB@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).