How to get a compilation warning

I am very surprised when I compile the following code without warning using g ++ 4.1.2 with -Wall -Wextra -Wconversion enabled.

I want g ++ to show me every warning in order to avoid potential harm. I have to stick with g ++ 4.1.2.

#include <stdint.h> #include <string> using namespace std; int main() { uint8_t u1=1; uint64_t u64=1000; string s1=""; u1=u64; // want warning here s1=u64; // want warning here s1=u1; } 
+7
c ++ g ++
source share
1 answer

I am afraid that GCC until 4.3 does not support this. The -Wconversion description -Wconversion changed between 4.2 and 4.3 to reflect the new warning behavior, and there is no indication that pre-4.3 GCC will check this.

+4
source share

All Articles