From: "Ralf W. Grosse-Kunstleve" <rwgk@cci.lbl.gov>
To: gcc@gcc.gnu.org
Cc: hahn@physics.mcmaster.ca, rwgk@boa.lbl.gov
Subject: Re: warning: assignment to `int' from `double'
Date: Wed, 27 Feb 2002 15:27:00 -0000 [thread overview]
Message-ID: <200202272316.g1RNGZZ57376@boa.lbl.gov> (raw)
> > operator+= etc. for operations on arrays. The array
> > element types can be custom types with overloaded
> > operators. Any cast buried in the array operator+= would
> > interfere with the semantics of the overloaded custom
> > operators.
>
> I'm not sure why this is relevant; the issue is implicit conversions,
> isn't it?
Consider an idealized array operator+=:
template <typename ElementType1,
typename ElementType2>
std::vector<ElementType1>&
operator+=(std::vector<ElementType1>& a1,
const std::vector<ElementType1>& a2) {
for(std::size_t i=0;i<a1.size();i++) a1[i] += a2[i];
return a1;
}
For built-in types this would be fine:
a[i] += ElementType1(a2[i]);
But for custom types with potentially multiple overloads
for operator+= this construct would result in unexpected
behavior.
> > 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.)
>
> not a strong argument; you need to reference the standard.
If the standard demands a warning it is counter-productive
in my case. I wish it would be possible to selectively
suppress the warning.
Thanks,
Ralf
next reply other threads:[~2002-02-27 23:16 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-02-27 15:27 Ralf W. Grosse-Kunstleve [this message]
-- strict thread matches above, loose matches on Subject: below --
2002-02-27 11:30 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=200202272316.g1RNGZZ57376@boa.lbl.gov \
--to=rwgk@cci.lbl.gov \
--cc=gcc@gcc.gnu.org \
--cc=hahn@physics.mcmaster.ca \
--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).