public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Ralf W. Grosse-Kunstleve" <rwgk@cci.lbl.gov>
To: gcc@gcc.gnu.org
Cc: neil@daikokuya.demon.co.uk, rwgk@boa.lbl.gov
Subject: Re: warning: assignment to `int' from `double'
Date: Wed, 27 Feb 2002 11:30:00 -0000	[thread overview]
Message-ID: <200202271925.g1RJPFe54346@boa.lbl.gov> (raw)

Neil Booth wrote:

> 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?

In my application a cast is not an option. I am overloading
operator+= etc. for operations on arrays. The array
element types can be custom types with overloaded
operators. Any cast burried in the array operator+= would
interfer with the semantics of the overloaded custom
operators.

gcc 3.0.x (incl. 3.0.4) is the only compiler that issues
the warning above. (I am also using various EDG derivatives
and Codewarrior.)

Thanks,
        Ralf

             reply	other threads:[~2002-02-27 19:25 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-02-27 11:30 Ralf W. Grosse-Kunstleve [this message]
  -- strict thread matches above, loose matches on Subject: below --
2002-02-27 15:27 Ralf W. Grosse-Kunstleve
2002-02-27 10:29 Ralf W. Grosse-Kunstleve
2002-02-27 11:14 ` Neil Booth

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200202271925.g1RJPFe54346@boa.lbl.gov \
    --to=rwgk@cci.lbl.gov \
    --cc=gcc@gcc.gnu.org \
    --cc=neil@daikokuya.demon.co.uk \
    --cc=rwgk@boa.lbl.gov \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).