This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/32525] Request for new warning: useless dynamic_casts
- From: "bangerth at dealii dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 27 Jun 2007 19:17:21 -0000
- Subject: [Bug c++/32525] Request for new warning: useless dynamic_casts
- References: <bug-32525-6477@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #4 from bangerth at dealii dot org 2007-06-27 19:17 -------
(In reply to comment #3)
> I think that's a good definition. My impression is that dynamic_cast is fairly
> expensive,
But only if the compiler can't know the actual type of an object (which
is exactly the case that you want to treat). If the actual type of an
object is known or if you are casting to a base class, dynamic_cast is as
cheap as static_cast.
> "I doubt anyone will ever implement this."
>
> I've gotten used to that. :)
Well, people implement what they consider important to them. PRs about
uninteresting
things will lie dormant until there are no interesting things left to
implement.
I think everyone's time would be better used if you tried to find cases
where gcc doesn't produce a no-op for the constructs you want to warn
about. That would be a missed-optimization, rather than a more or less
uninteresting warning, and would receive more interest.
W.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32525