This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/50011] [C++0x] warning: narrowing conversion of 'i' from 'short unsigned int' to 'int' inside { } [-Wnarrowing]
- From: "zsojka at seznam dot cz" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 8 Aug 2011 07:54:54 +0000
- Subject: [Bug c++/50011] [C++0x] warning: narrowing conversion of 'i' from 'short unsigned int' to 'int' inside { } [-Wnarrowing]
- Auto-submitted: auto-generated
- References: <bug-50011-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50011
--- Comment #2 from Zdenek Sojka <zsojka at seznam dot cz> 2011-08-08 07:53:54 UTC ---
(In reply to comment #1)
> That may be true on your platform, but I don't think it is guaranteed to be
> true in general. I don't know if that explains the warning...
Yes, I should have mentioned the target is x86_64-unknown-linux-gnu.
Generally, the code added in r177215:
+ if ((TYPE_PRECISION (type) < TYPE_PRECISION (ftype)
+ || TYPE_UNSIGNED (type) != TYPE_UNSIGNED (ftype))
looks like no unsigned type can ever be losslessly converted to a signed type
(even when it's "longer"), which is not true (on the other hand, an unsigned
type can never represent all values of any signed type, because it can't
represent negative numbers). But of course, I am not a language lawyer at all.