http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50011
--- Comment #5 from Zdenek Sojka <zsojka at seznam dot cz> 2011-08-08 11:03:29 UTC --- (In reply to comment #3) > + if ((TYPE_PRECISION (type) < TYPE_PRECISION (ftype) > + || TYPE_UNSIGNED (type) != TYPE_UNSIGNED (ftype)) > > looks wrong. I guess it should be > > if ((TYPE_PRECISION (type) < TYPE_PRECISION (ftype) > || (TYPE_PRECISION (type) == TYPE_PRECISION (ftype) > && TYPE_UNSIGNED (type) != TYPE_UNSIGNED (ftype))) > > instead. Wouldn't that allow 'signed short' -> 'unsigned int' conversions? Maybe if ((TYPE_PRECISION (type) < TYPE_PRECISION (ftype) || (TYPE_PRECISION (type) == TYPE_PRECISION (ftype) && TYPE_SIGNED (type) && TYPE_UNSIGNED (ftype)) || (TYPE_UNSIGNED (type) && TYPE_SIGNED (ftype)) if it means "converting to a smaller type OR converting an unsigned type to a signed type of the same precision OR convering signed to unsigned". But then the condition gets quite complicated I would wonder if there isn't a macro for that check somewhere... (also, it might be wrong) Maybe simpler would be to just compare type's and ftype's min/max values, if there is a simple way do to that. (I don't really have GCC sources by hand) (In reply to comment #4) > (In reply to comment #2) > > 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++) It gives a warning probably because of a mistake in the gcc sources.