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: "marc.glisse at normalesup dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 8 Aug 2011 10:13:21 +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 #4 from Marc Glisse <marc.glisse at normalesup dot org> 2011-08-08 10:12:58 UTC ---
(In reply to comment #2)
> 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.
So (if I follow you) g++ is complaining (with a warning, not an error) because
your code is illegal on some other platforms? (I don't think anything forbids
CHAR_BIT==64 and sizeof(long long)==1 in C/C++)