This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: CCP propagating conditional expression constants


Gabriel Dos Reis wrote:
> Mark Mitchell <mark@codesourcery.com> writes:
> 
> | Sebastian Pop wrote:
> | 
> | > if (x == 0)
> | >  a = b / x;
> | 
> | If we end up warning about this from the optimizers (and, at this point,
> | we all know that's not my favorite idea), then I think we should avoid
> | warning about:
> | 
> |   if (x == 0 && false)
> |     a = b / x;
> 
> I really favor the idea of stopping warning from the optimizers.
> However, I don't know yet (and I have not seen) an alternative that
> would be better than current situation.  Do you have something
> specific in ming for replacements?

I think we should just accept lower fidelity warnings, emitted from the
front end.  I think we should warn about the obvious cases that front
ends can detect, and not try to emit warnings based on more complex
anlaysis.  That will result in missing some useful warnings, but may
also reduce false positives.  It will eliminate the -g vs. -O2
differences and match what most other compilers do.

If we want to keep the optimizer-based warnings, I think we should
segregate them into a separate category, rather than enabling them as
part of the usual warnings.  The optimizer-based warnings are more like
"lint" or other, more sophisticated, source-based analysis tool
warnings, like Insure++.  It makes sense to build some of that
technology into the compiler, but I think it's unfortunate that there
are things we don't warn about at -O0, and that our warning behavior
varies from target to target, release to release, optimization levels, etc.

-- 
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]