gcc warning about return value truncation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux