Open Quuxplusone opened 9 years ago
Bugzilla Link | PR24496 |
Status | NEW |
Importance | P normal |
Reported by | Ehsan Akhgari [:ehsan] (ehsan.akhgari@gmail.com) |
Reported on | 2015-08-19 07:45:54 -0700 |
Last modified on | 2015-08-19 11:53:21 -0700 |
Version | unspecified |
Hardware | PC All |
CC | alexfh@google.com, djasper@google.com, klimek@google.com |
Fixed by commit(s) | |
Attachments | |
Blocks | |
Blocked by | |
See also |
Do you have a real-life use case for this?
(In reply to comment #1)
> Do you have a real-life use case for this?
Yes. This bug breaks this code in Mozilla: <http://mxr.mozilla.org/mozilla-
central/source/dom/media/systemservices/MediaParent.h?rev=9e4579598ba8#57>.
Here, Parent is instantiated with two types, one which has a virtual
destructor, and one without one.
But is there a good reason for NonE10s not to have a virtual destructor? C++ compilers will usually warn you about that.
(In reply to comment #3)
> But is there a good reason for NonE10s not to have a virtual destructor? C++
> compilers will usually warn you about that.
We never delete one of these objects through a NonE10s pointer, but I guess we
could add a virtual destructor to NonE10s. However, I still think that the
rewrite of the code in comment 0 is wrong even for f(), since the base class
type may not have a virtual f().
I understand. But I am not convinced that never using override just because there is some base class depending on a template parameter is the right solution. I think the more common use case will still be that you'd want this override.
Not using the override can be just as wrong. People still might want to learn that they have mis-typed some method name or maybe even that they are instantiating this class with an incompatible type name.
In truth, I to some extent consider this construct a flaw in the language specification. There is simply no right thing for clang-tidy to do. Thus, we should make it do the right thing in the majority of cases. So far, I am still convinced that adding override is better in the majority of cases. I have yet to see a use case where people use this pattern deliberately in real-life code.
OK, fair enough!