How do promotion rules work when the signedness on either side of a binary operator differ? [duplicate]
问题 This question already has answers here : Implicit type conversion rules in C++ operators (9 answers) Closed last year . Consider the following programs: // http://ideone.com/4I0dT #include <limits> #include <iostream> int main() { int max = std::numeric_limits<int>::max(); unsigned int one = 1; unsigned int result = max + one; std::cout << result; } and // http://ideone.com/UBuFZ #include <limits> #include <iostream> int main() { unsigned int us = 42; int neg = -43; int result = us + neg; std