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 #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++)


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