<<< Date Index >>>     <<< Thread Index >>>

Re: [PATCH 7 of 9] Fix comparison signedness warning



On 2010-08-07 10:04:01 +0200, Matthias Andree wrote:
> Of course Vincent can validly argue that the compiler is too dumb to
> figure that the code isn't reached for chunk < 0, but it's a
> context-sensitive check - so it's expensive because it needs to
> track the whole decision tree. clang in analyzer mode might figure
> that out, but it's sloooooow that way.

Note that the normal user wouldn't run the compiler with -Wextra.
This option, in particular -Wsign-compare (implied by -Wextra), is
mainly for developers/testers, and to be really useful, it needs at
least basic value range propagation: no need to analyse the whole
tree in this case. So, no, it isn't expensive. It's surprising that
the -ftree-vrp option (implied by -O2) doesn't avoid the warning
here... I've checked on the GCC Bugzilla and found:

  http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38470

which is exactly the problem here. Perhaps this is one of the reasons
why -Wsign-compare is enabled by -Wextra but not by -Wall (though VRP
wouldn't avoid all the warnings).

-- 
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / Arénaire project (LIP, ENS-Lyon)