[vtk-developers] new warnings: explicitly assigning a variable to itself
Brad King
brad.king at kitware.com
Tue Jan 18 10:33:47 EST 2011
On 1/18/2011 10:24 AM, Jim Miller wrote:
> It was probably done years ago as a means to *prevent* warnings in the
> generated code. I recall a path through the code where the variable
> would not be referenced. So we would through in a foo=foo; line to
> quiet the compilers. Now it seems like there is a warning that tells
> you when this is done :)
Thanks.
Yeah, modern optimizing compilers can even detect when the result
of an assignment is not used. A nice way to reference (possibly)
unused variables to avoid warnings is
(void)foo;
in C or alternatively
static_cast<void>(foo);
in C++. Since the code is generated then perhaps some of these
variables wont' be used. I think changing
error = 0; error = error;
to
error = 0; (void)error;
will take care of these.
-Brad
More information about the vtk-developers
mailing list