I compile this code with g++ -Wall, get no warnings/errors:
#include "stdio.h"
int main() {
long x = 1000000000000;
int y = x;
printf("%ld %d\n", x, y);
return 0;
}
The output is something one would expect:
1000000000000 -727379968
But shouldn't the compiler prevent from implicit conversion/truncation in this case?
g++ (GCC) 4.1.2 20071124 (Red Hat 4.1.2-42)