This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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.




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]