Please see the following code:
#include <type_traits>
int main()
{
using T = short;
auto x = T(1) + T(1);
static_assert(std::is_same_v<decltype(x), T>);
}
It seems that the above static_assert fails for all of gcc, clang, and msvc and I can't see why. The assertion still fails if I change short into any of bool, char, signed char, unsigned char, and unsigned short, because for all of those cases decltype(x) is deduced to be int.
Is this the correct behavior given what's explained in https://en.cppreference.com/w/cpp/language/operator_arithmetic?