------- Comment #3 from redi at gcc dot gnu dot org  2010-06-11 11:37 -------
'y' and 'C' are both promoted to int and 'y' is not a constant, so the
resulting value cannot be proven to fit in a char, so it's a narrowing
conversion.

If you make 'y' a const int then the value y+C is a constant and can be proven
not to narrow.

The fact that the optimiser knows y=42 is irrelevant, the language specifies
that y is not a constant, and whether the code is valid or not has to be
independent of optimisations such as value propagation.

I think gcc is correct here.


-- 


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

Reply via email to