http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52106

Vincent Lefèvre <vincent-gcc at vinc17 dot net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
         Resolution|INVALID                     |
            Summary|missing                     |warning for useless
                   |-Wunused-but-set-variable   |assignments
                   |warning with the a = b =    |
                   |... construct               |

--- Comment #2 from Vincent Lefèvre <vincent-gcc at vinc17 dot net> 2012-02-03 
13:28:39 UTC ---
Then there should be another warning. So, this is a request for a warning for
assignments that are obviously useless (thus maybe a typo in the code or old
code that could be removed...). It should cover variables set but not used
outside the full expression where they are set. The code

int foo (void)
{
  int a, b;
  a = b = 0;
  return a;
}

gives an example. It could be written:

int foo (void)
{
  int a;
  a = 0;
  return a;
}

"a = b = ...;" is generally used as a shortcut for "a = ...; b = ...;", and if
it isn't (because the behavior would be different at compile time or at run
time), there should be a warning against this construct.

Reply via email to