ksu.shadura added a comment. In https://reviews.llvm.org/D45766#1098823, @Quuxplusone wrote:
> 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`...) Thanks for your opinion, your guess was right! It is a unit-test, so seems we need to try to suppress warnings on our side. Repository: rL LLVM https://reviews.llvm.org/D45766 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits