This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Fw: I'd like to get warnings on loss of data during implicit conversions
- From: William Mahoney <wmahoney at mail dot unomaha dot edu>
- To: gcc-help at gcc dot gnu dot org
- Date: Mon, 20 Sep 2010 10:20:17 -0500
- Subject: Fw: I'd like to get warnings on loss of data during implicit conversions
Jeff:
I believe that the standard just says that sizeof(short) <= sizeof(int) <=
sizeof(long). It does not guarantee that "int" on machine A is the same
as "int" on machine B. Same fro "short" and same for "long". As a result,
it is possible that a narrowing cast (that's what this is) loses precision
on machine A but not on machine B. This depends on the machine, the
compiler, and the moon phase when the compiler was built.
Bill
----- Forwarded by William Mahoney/FACSTAFF/UNO/UNEBR on 09/20/2010 10:18
AM -----
From:
Jeff Saremi <jeffsaremi@yahoo.com>
To:
gcc-help@gcc.gnu.org
Date:
09/20/2010 10:15 AM
Subject:
I'd like to get warnings on loss of data during implicit conversions
Sent by:
gcc-help-owner@gcc.gnu.org
When i compile my c or C++ code under Microsoft compiler I get warnings
like the following:
warning C4244: 'argument' : conversion from 'unsigned long' to 'uint16
', possible loss of data
However, compiling the same code with Gcc/G++ does not produce this
warning at all?
My question is:
- is this a standard (i mean ISO) warning? or is it a courtesy warning?
- Does gcc have something similar to this? If so which option is that?
I have tried the following individiaully and in combination to no avail:
-Wall, -Wextra, -Wconversion
thanks
jeff