On 12-10-2014 16:40, Jon A. Cruz wrote:
Clang has a few issues (warning on redundant assignment being one)
I think in many cases, this particular warning can flag bugs, where someone accidentally made a typo or used one name for two variables. This means that fixing these errors is actually not a straight forward task!!! However, there are also usecases where it is good to overwrite a variable with a new value, to ease future extension of the code.
How about we add an idiom for silencing that particular error? We need two idioms to let the other devs and clang know, that some variable is intentionally unused.
1. new variable max, never used: double min = ...; //double max = ...;
2. update variable max, never used after: #include "helper/static_analysis.h" min = ...; max = ...; intentionally_unused(max);
I am not sure, but perhaps there is a way to silence the analyzer iff max is unused afterwards. Perhaps "x = x;". Note that this would have to also not give warnings for gcc. Hence the small helper header file, with a compiler-dependent macro "intentionally_unused".
-Johan