Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get compile warning

Tags:

c++

g++

I'm quite surprised when I compile the following code without any warning using g++ 4.1.2 with -Wall -Wextra -Wconversion enabled.

I want g++ to show me every warning to avoid potential harm. I have to stick to 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;
}
like image 548
lyman Avatar asked Jul 09 '10 07:07

lyman


1 Answers

I'm afraid GCC before 4.3 doesn't seem to support this. The description of -Wconversion changed between 4.2 and 4.3 to reflect the new warning behavior, and there is no indication that pre-4.3 GCC would check for this.

like image 194
Philipp Avatar answered Nov 02 '22 07:11

Philipp