This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Conversion from double to int by default
- From: Manuel López-Ibáñez <lopezibanez at gmail dot com>
- To: Ivo Hanak <hanak at byte dot cz>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Fri, 9 Apr 2010 09:13:37 +0200
- Subject: Re: Conversion from double to int by default
- References: <4BBEBECE.8050103@byte.cz>
On 9 April 2010 07:44, Ivo Hanak <hanak@byte.cz> wrote:
> ?I tried to search the web but I still do not have any clue why it converts
> from double to int by default. This seems pretty dangerous to me. Am I
> missing something?
Because that is how the C++ standard says it should be and g++ is a
C++ compiler so it (aims to) implement the C++ standard. You can use
-Wconversion to get a warning and -Werror=conversion to get an error
for that line. You should also read about -Wall, -Wextra and -Werror
in the documentation.
Cheers,
Manuel.