This is the mail archive of the gcc-bugs@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]

[Bug c++/44500] [C++0x] Bogus narrowing conversion error



------- 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


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