Is there any gcc flag to warn about this? #include <iostream> #include <cstdint> int16_t func() { int32_t num = INT32_MAX; std::cout << "func() called " << num << std::endl; return num; } int main() { int32_t val = func(); std::cout << "return value is " << val << std::endl; } The return value of func() was truncated because the return type is accidentally written as int16_t Thanks, Yubin