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++/50011] [C++0x] warning: narrowing conversion of 'i' from 'short unsigned int' to 'int' inside { } [-Wnarrowing]


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.


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