6
int i = 3.1 / 2

does not cause any warnings,even with -Wall option.Sometimes,I would like to know where precision lose.Why gcc does not support this warning,while msvc support this one?

thanks.

EDIT: my gcc -v shows

Configured with: ../../gcc-4.4.1/configure --prefix=/mingw --build=mingw32 --enable-languages=c,ada,c++,fortran,objc,obj-c++ --disable-nls --disable-win32-registry --enable-libgomp --enable-cxx-flags='-fno-function-sections -fno-data-sections' --disable-werror --enable-threads --disable-symvers --enable-version-specific-runtime-libs --enable-fully-dynamic-string --with-pkgversion='TDM-2 mingw32' --enable-sjlj-exceptions --with-bugurl=http://www.tdragon.net/recentgcc/bugs.php

Jichao
  • 40,341
  • 47
  • 125
  • 198
  • 2
    It may be useful to know that -Wall does not turn on all warnings currently supported by the compiler. It is a set of warnings that were available several years ago. Using -Wextra adds a few more, though I'm not sure whether even that includes a warning for truncation. – Dipstick Jan 04 '10 at 12:18
  • 5
    Arguably, you should first have a warning for the "3.1", since this number cannot be represented exactly in an IEEE 754 floating-point double. And this may be the reason why gcc doesn't warn you: you would get so many warnings that they would not be useful. – Pascal Cuoq Jan 04 '10 at 12:19
  • 1
    @chrisharris:even with -Wall -Wextra -ansi -pedantic,it does not work. – Jichao Jan 04 '10 at 12:41
  • @Pascal Cuoq:I think it doesn't matter whether this specific number could be represented with IEEE 754 and gcc does not warn with some other arbitrary numbers. – Jichao Jan 04 '10 at 12:44
  • @Pascal Cuoq, big props for carrying this to its logical conclusion and showing the absurdity. :-) – R.. GitHub STOP HELPING ICE Jul 13 '10 at 09:26
  • For the record, `-Wall` (per http://gcc.gnu.org/onlinedocs/gcc-4.8.0/gcc/Warning-Options.html ) includes only warnings for constructs where (a) the code is almost certainly wrong, and (b) whether or not it was wrong, it is easy to modify the code to suppress the warning. The idea is that you should have no trouble keeping your code `-Wall`-clean. (The name is unfortunate, but was chosen decades ago and now we're stuck with it.) – zwol Apr 16 '13 at 14:41

1 Answers1

11

-Wconversion warns for implicit conversion.

Andy
  • 1,035
  • 2
  • 9
  • 14
  • Does mingw recognise this option, please check using gcc -v option to get more details. – Andy Jan 04 '10 at 13:45