long int / int assignment warnings

andre maute andre.maute@gmx.de
Sun Jun 1 14:11:00 GMT 2014


Hi list,

my g++ is
gcc version 4.8.2 20131212 (Red Hat 4.8.2-7) (GCC)

-Wconversion will issue a warning for the second cout line

Is there a compiler flag to force a warning for the first cout line?

------------------------------------
// compile with -std=c++11 -Wconversion
#include <iostream>
#include <cstdint>
int main()
{
     { int32_t x = 1; int64_t y = x; std::cout << y << std::endl; }
     { int64_t x = 2; int32_t y = x; std::cout << y << std::endl; }
     return 0;
}
-------------------------------------

Andre



More information about the Gcc-help mailing list