[Bug c++/32525] Request for new warning: useless dynamic_casts
--- Comment #8 from manu at gcc dot gnu dot org 2010-02-21 00:17 --- (In reply to comment #5) I filed the bug because it seems like this would be at least marginally useful, and this way people can find it / read the discussion / whatever. Even if the end result is WONTFIX, that at least lets anyone in the future who searches the bug database know what the situation is. Fair enough. Thanks everybody for the comments. Closing then. -- manu at gcc dot gnu dot org changed: What|Removed |Added CC||manu at gcc dot gnu dot org Status|UNCONFIRMED |RESOLVED Resolution||WONTFIX http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32525
Re: [Bug c++/32525] Request for new warning: useless dynamic_casts
lloyd at randombit dot net [EMAIL PROTECTED] writes: | I think that's a good definition. My impression is that dynamic_cast is fairly | expensive, well, I don't think GCC should be getting into the business of warning about expensive operations. -- Gaby
[Bug c++/32525] Request for new warning: useless dynamic_casts
--- Comment #6 from gdr at cs dot tamu dot edu 2007-07-14 13:02 --- Subject: Re: Request for new warning: useless dynamic_casts lloyd at randombit dot net [EMAIL PROTECTED] writes: | I think that's a good definition. My impression is that dynamic_cast is fairly | expensive, well, I don't think GCC should be getting into the business of warning about expensive operations. -- Gaby -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32525
[Bug c++/32525] Request for new warning: useless dynamic_casts
--- Comment #7 from sebor at roguewave dot com 2007-07-15 00:03 --- In cases when the compiler can figure out that the cast is unnecessary it would be even better if it would optimize it away than to complain to the user about not being able to do it. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32525
[Bug c++/32525] Request for new warning: useless dynamic_casts
--- Comment #1 from pinskia at gcc dot gnu dot org 2007-06-27 18:14 --- However it would be nice if the programmer was notified about them, since even if there is no run-time cost, there is a source-level increase in complexity which can easily be avoided (and there may well be run-time costs involved with other compilers). If this warning comes into GCC, we should disable it for templates. The main reason why I say that is because if you do: templatetypename A, typename B A* f(B *b) { return dynamic_castA*(b); } And then instanitite it where typename A == typename B, it is hard to avoid the warning in this case. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32525
[Bug c++/32525] Request for new warning: useless dynamic_casts
--- Comment #2 from bangerth at dealii dot org 2007-06-27 18:53 --- This strikes me as one of the things that hardly anybody would ever find useful. I mean, yes it happens, but no, it doesn't hurt, and I haven't seen such code written in the first place ever. Warnings are for cases where either code may not do what you expect, or where a certain way of coding has a significant cost that can be avoided. I doubt anyone will ever implement this. W. -- bangerth at dealii dot org changed: What|Removed |Added CC||bangerth at dealii dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32525
[Bug c++/32525] Request for new warning: useless dynamic_casts
--- Comment #3 from lloyd at randombit dot net 2007-06-27 19:06 --- I haven't seen such code written in the first place ever. Neither had I, until I found out it is endemic in a large project at work. I'd just as soon write a script to find these cases, but figuring out what the type of the casted-from pointer/reference is can be somewhat nontrivial. Warnings are for cases where either code may not do what you expect, or where a certain way of coding has a significant cost that can be avoided. I think that's a good definition. My impression is that dynamic_cast is fairly expensive, and while it is great that GCC noops out this case I suspect not all compilers will do the same; at this point I'm not even sure that GCC does it consistently. So I'd figure it a reasonable case for a warning as per your second condition. I doubt anyone will ever implement this. I've gotten used to that. :) -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32525
[Bug c++/32525] Request for new warning: useless dynamic_casts
--- 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
[Bug c++/32525] Request for new warning: useless dynamic_casts
--- Comment #5 from lloyd at randombit dot net 2007-06-27 19:33 --- I filed the bug because it seems like this would be at least marginally useful, and this way people can find it / read the discussion / whatever. Even if the end result is WONTFIX, that at least lets anyone in the future who searches the bug database know what the situation is. I'm sorry if I made it sound like I was expecting this to be implemented immediately or anything like that. That is not the case at all; even serious problems like code miscompilations can go a good while without being analyzed or fixed due to time and resource constraints, and something like this naturally falls much (much) deeper into the queue of things to work on. Thus my comment about being used to it, I know there is are many more interesting/important things to work on in GCC. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32525