https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78964
Manuel López-Ibáñez <manu at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |manu at gcc dot gnu.org --- Comment #6 from Manuel López-Ibáñez <manu at gcc dot gnu.org> --- (In reply to Jakub Jelinek from comment #3) > ++m is no different from m = m + 1;, both read the variable content before > writing it again, and with the current infrastructure it would be terribly > hard to figure out that the var is read solely to write its value again. > Even trying to explain this in the documentation would be hard. Well, we could just say that uses that are assigned to itself are not considered uses for the purposes of Wunused-but-set. This would include not only ++m but also m += 2 and m = m + x, so we would warn about: void f( int n) { int m = 0; m = m + n; } I thought there was an open PR about this and another about the simpler "m = m" case, but I cannot find them.