[Development] Branch for adding Q_DECL_OVERRIDEs

Marco Bubke Marco.Bubke at qt.io
Thu Oct 27 19:49:09 CEST 2016


Final can be used by the compiler by optimazing the virtual call away but it has the drawback that you cannot overload it in testing code to mock or fake a class. 


On October 27, 2016 18:36:01 Giuseppe D'Angelo <giuseppe.dangelo at kdab.com> wrote:

> Hi,
>
> please keep the discussion on the mailing list, so others can chime in.
>
> Il 27/10/2016 17:47, Александр Волков ha scritto:
>> 27.10.2016 18:19, Giuseppe D'Angelo пишет:
>>> Don't worry too much. To minimize merge conflicts I'm quite sure we'll
>>> keep using Q_DECL_OVERRIDE as long as 5.6 will be open. So use that :)
>>> We'll do a cleanup pass in the future.
>> 
>> BTW, should 'override' be added in the following case:
>> struct A {
>>    virtual void f();
>> };
>> struct B : A {
>>    void f() final; // override also?
>> };
>> ?
>> 
>> Unfortunately gcc reports a warning for f() 
>> (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78010)
>> There some such places in Qt, for example in 
>> corelib/kernel/qeventdispatcher_glib_p.h,
>> where Q_DECL_OVERRIDE should be added to make it compilable with gcc 
>> [-Werror, -Wsuggest-override].
>> The question is whether to follow a reasonable style
>> https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Rh-override
>> or a style forced by gcc?
>
> To be honest I don't know if we have a consensus on this. (How many
> cases of "final" in our classes do we have anyhow?)
>
> Cheers,
> -- 
> Giuseppe D'Angelo | giuseppe.dangelo at kdab.com | Senior Software Engineer
> KDAB (UK) Ltd., a KDAB Group company | Tel: UK +44-1625-809908
> KDAB - Qt, C++ and OpenGL Experts
>



More information about the Development mailing list