[Development] override keyword on destructors

Philippe philwave at gmail.com
Mon Aug 20 17:16:00 CEST 2018


I have recently used Resharper C++ to automatically add override to destructor declarations, on a very large application.
Conclusion: very instructive with reflexions such as: "ha ha! this base class is virtual!"

IOW, override on dtor reveals information which can be useful to understand code.

Philippe

On Mon, 20 Aug 2018 13:08:36 +0100
Sérgio Martins via Development <development at qt-project.org> wrote:

> Hi,
> 
> 
> Looks like some 'override' keywords crept into a few destructors. This 
> is probably because clang-tidy warns about it (and now QtCreator).
> 
> IMO we should avoid it, as it's misleading. Dtors are a special case and 
> have completely different semantics. They don't replace their base class 
> dtors. They're chained instead.
> 
> This is not 100% consensual, some people like to use it.
> 
> But it's discouraged by the Cpp Core Guidelines [1] ; gcc's 
> -Wsuggest-override doesn't suggest it for dtors and neither does clang's 
> -Winconsistent-missing-override.
> 
> So clang-tidy is the one odd out.
> 
> I'll update the coding conventions if nobody opposes.
> 
> 
> 
> [1] - 
> https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Rh-override
> 
> Regards,
> -- 
> Sérgio Martins | sergio.martins at kdab.com | Senior Software Engineer
> Klarälvdalens Datakonsult AB, a KDAB Group company
> Tel: Sweden (HQ) +46-563-540090, USA +1-866-777-KDAB(5322)
> KDAB - The Qt, C++ and OpenGL Experts
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/development





More information about the Development mailing list