This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [tree-ssa] Statement with no effect warning
Jan Hubicka wrote:
I see now that c-simplify already has code to do the warning. I just
got caught by checking code and the fact that
expr_with_side_effect == expr
does not construct statement with no side effects. Do we want some
scheme of warning for non-void expressions whose results is ignored or
it is way to the hell? (definitly calls are such expressions where we
don't want warning like some lint checkers do)
I've seen such no-op constructs used very often to type-check
macro arguments, such as in include/linux/kernel.h:
/*
* min()/max() macros that also do
* strict type-checking.. See the
* "unnecessary" pointer comparison.
*/
#define min(x,y) ({ \
const typeof(x) _x = (x); \
const typeof(y) _y = (y); \
(void) (&_x == &_y); \
_x < _y ? _x : _y; })
Ok, some people are sensitive enough to cast the expression
to void just in case, but we'll be breaking lots of code like
this by issuing a warning.
Despite the potential breakage of legacy code, I'd favour
such an addition. Would it make sense to ignore this warning
when -Werror is also specified?
--
// Bernardo Innocenti - Develer S.r.l., R&D dept.
\X/ http://www.develer.com/