This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/44500] [C++0x] Bogus narrowing conversion error
- From: "redi at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 11 Jun 2010 11:37:43 -0000
- Subject: [Bug c++/44500] [C++0x] Bogus narrowing conversion error
- References: <bug-44500-11646@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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