g++ -Wall not warning about double-> int cast

后端 未结 3 483
名媛妹妹
名媛妹妹 2020-12-03 14:02

In the following snippet no warnings are produced. g++4.4.3 -Wall -pedantic

//f is
void f(int );

f(3.14);
double d = 3.14;
int i = d+2;

I

3条回答
  •  猫巷女王i
    2020-12-03 14:10

    $ gcc -Wconversion test.c
    
    test.c: In function ‘main’:
    test.c:3: warning: conversion to ‘int’ from ‘double’ may alter its value
    

提交回复
热议问题