This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
implicit narrowing conversion.
- From: Adam Sulmicki <adam at cfar dot umd dot edu>
- To: gcc at gcc dot gnu dot org
- Date: Tue, 22 Jun 2004 13:56:20 -0400 (EDT)
- Subject: implicit narrowing conversion.
hello,
shouldn't this code below generate warnings on "implicit narrowing
conversion", on:
1) "i=f" assignment as well as
2) on conversion on return from float to int?
int main() {
double f;
int i;
i = f;
return f;
}
I could not get the said above code to generate warnings with any flags on
the two cases mentioned above.
[adam@mtdew adam]$ gcc -Wall -W -pedantic test2.c -O0
[adam@mtdew adam]$ gcc -v
gcc version 3.3.3 20040412 (Red Hat Linux 3.3.3-7)
When I lookup C99 - August 3, 1998 WG14/N843,
In appendinx J it says :
[#1] An implementation may generate warnings in many
situations, none of which are specified as part of this
International Standard. The following are a few of the more
common situations.
-- An implicit narrowing conversion is encountered, such
as the assignment of a long int or a double to an int,
or a pointer to void to a pointer to any type other
than a character type (6.3).
so it seems like it would be a nice feature to have.