<div dir="ltr"><div>Hi Gilles</div><div><br></div><div>This is completely valid code if the virtual is missing. So I don't think there is a compiler error or warning. See the attached example. <br></div><div><br></div><div>I would advise to use the compiler flag -Werror=suggest-override. So you can guarantee that all overridden functions are at least virtual. <br></div><div><br></div><div>Hope to help you with this information. <br></div><div><br></div><div>Cheers</div><div>Marcel<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Nov 13, 2020 at 4:16 PM Gilles Caulier <<a href="mailto:caulier.gilles@gmail.com">caulier.gilles@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">A partial response can be found here :<br>
<br>
<a href="https://stackoverflow.com/questions/1853896/is-it-possible-to-override-a-non-virtual-method" rel="noreferrer" target="_blank">https://stackoverflow.com/questions/1853896/is-it-possible-to-override-a-non-virtual-method</a><br>
<br>
This is typically possible but highly not recommended and not portable<br>
everywhere... as i understand...<br>
<br>
Gilles<br>
<br>
Le ven. 13 nov. 2020 à 16:11, Gilles Caulier<br>
<br>
<<a href="mailto:caulier.gilles@gmail.com" target="_blank">caulier.gilles@gmail.com</a>> a écrit :<br>
><br>
> And it's the same for MetaEngine::applyChanges() ....<br>
><br>
> Gilles<br>
><br>
> Le ven. 13 nov. 2020 à 16:10, Gilles Caulier<br>
> <<a href="mailto:caulier.gilles@gmail.com" target="_blank">caulier.gilles@gmail.com</a>> a écrit :<br>
> ><br>
> > Hi, all,<br>
> ><br>
> > I currently review all Clazy static analyzer reports, and i plan to<br>
> > merge DMetadata class to MetaEngine.<br>
> ><br>
> > While reviewing the code I discovered that MetadaEngine::save() is<br>
> > implemented into DMetadata without being declared as virtual.<br>
> ><br>
> > I'm surprised to not see a G++ warning about this code, which can<br>
> > introduce side effects... Look by yourself :<br>
> ><br>
> > <a href="https://invent.kde.org/graphics/digikam/-/blob/master/core/libs/metadataengine/engine/metaengine.h#L372" rel="noreferrer" target="_blank">https://invent.kde.org/graphics/digikam/-/blob/master/core/libs/metadataengine/engine/metaengine.h#L372</a><br>
> ><br>
> > <a href="https://invent.kde.org/graphics/digikam/-/blob/master/core/libs/metadataengine/dmetadata/dmetadata.h#L95" rel="noreferrer" target="_blank">https://invent.kde.org/graphics/digikam/-/blob/master/core/libs/metadataengine/dmetadata/dmetadata.h#L95</a><br>
> ><br>
> > How is it technically possible ?<br>
> ><br>
> > Best<br>
> ><br>
> > Gilles Caulier<br>
</blockquote></div>