I have a chunk of code generated by a script, and the code involves some integer constants. I ran into a strange problem: one of the constants is equal to -2147483648 (minimum signed int32), and Visual Studio generates the following error: unary minus operator applied to unsigned type, result still unsigned
(which is especially strange since I don't have treat warnings as errors enabled).
Apparently it sees an integer that doesn't fit in the signed type, makes it unsigned, and only then applies the unary minus. I suppose the result would still be correct as it will be casted to int
(which is actually a template argument), but I'd like to avoid the warning. Is it just a VS feature or does the standard have anything to say about it?
Here's the offending line:
typedef Proto_Int<-2147483648,32> Typeinfo_77;
See Question&Answers more detail:os