[PATCH] D45766: [Sema] Add -Wno-self-assign-overloaded
Arthur O'Dwyer via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon May 14 18:35:45 PDT 2018
Quuxplusone added a comment.
In https://reviews.llvm.org/D45766#1097797, @ksu.shadura wrote:
> Thank you for the test example! I got your point, but I wanted to ask if it should be like this for commutative operations?
> In our case it is actually matrix, and subtraction of matrices is not commutative operation..
Mathematical commutativity has nothing to do with this diagnostic. The diagnostic is complaining that `m1 -= m1` produces a trivial effect (in this case `m1.clear()`) via a syntax that might indicate that the programmer made a typo (i.e. the compiler suspects that you meant `m -= m1` or something).
>From the function name `stress_...`, I infer that this is a unit-test. This warning is known to give "false positives" in unit-test code, where one often actually wants to achieve trivial effects through complicated code. The current recommendation there, AFAIK, is either to write something like
m1 -= static_cast<TMatrixD&>(m1); // hide the self-subtraction from the compiler
or else to add `-Wno-self-assign-overloaded` to your compiler flags. (libc++'s test suite already passes `-Wno-unused-command-line-argument -Wno-attributes -Wno-pessimizing-move -Wno-c++11-extensions -Wno-user-defined-literals -Wno-conversion -Wno-unused-local-typedef -Wno-#warnings`, for example.)
(That said, I continue to think that this diagnostic produces more noise than signal, and wish it weren't in `-Wall`...)
Repository:
rL LLVM
https://reviews.llvm.org/D45766
More information about the cfe-commits
mailing list