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!

Reply via email to