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]

Re: warning: assignment to `int' from `double'


Ralf W. Grosse-Kunstleve wrote:-

> The following code generates warnings with gcc 3.0.3:
> 
> int main()
> {
>   int i;
>   double d;
>   i = 0;
>   i += d;
>   return 0;
> }
> 
> g++ -g z.cpp -o z
> 
> z.cpp: In function `int main()':
> z.cpp:6: warning: assignment to `int' from `double'
> z.cpp:6: warning: argument to `int' from `double'
> 
> Is it possible to suppress this warning without resorting to -w?

Have you tried a cast?

Neil.


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