On Thu, Jul 03, 2025 at 12:10:10AM +0200, Jean-Marc Lasgouttes wrote:
> Le 02/07/2025 à 18:16, Scott Kostyshak a écrit :
> > Compiling with GCC and -Woverloaded-virtual gives 5 warnings. Are they
> > worth addressing?
> > 
> >  From what I understand, the main way to address them is via a "using" 
> > statement
> > (https://stackoverflow.com/questions/18515183/c-overloaded-virtual-function-warning-by-clang)
> 
> Are you sure you get only 5 warnings? You should get one for each inset
> class, basically. And now that I compile, I see LOTS of them.

Sorry, indeed that was misleading. I hacked together a command to try to
pick out the unique warnings. I don't know if it actually does what I
want:

  # make.log is the redirected output of "make".
  grep "\[-W.*\]" "make.log" | sort | uniq -c | grep -o "\[-W.*\]" | sort | 
uniq -c | sort -b -n

> Anyway, these warnings are of three types:
> 
> > 
> > src/insets/Inset.h:217:22: warning: ‘virtual void 
> > lyx::Inset::draw(lyx::PainterInfo&, int, int, const 
> > lyx::frontend::InputMethod*, lyx::pos_type) const’ was hidden 
> > [-Woverloaded-virtual=]
> >    217 |         virtual void draw(PainterInfo &, int, int, 
> > frontend::InputMethod const *,
> >        |                      ^~~~
> > src/insets/InsetExternal.h:139:14: note:   by ‘virtual void 
> > lyx::InsetExternal::draw(lyx::PainterInfo&, int, int) const’
> >    139 |         void draw(PainterInfo & pi, int x, int y) const override;
> >        |              ^~~~
> 
> For the draw() issue, I see three solutions:
> 1/ rename the draw() version with more parameters to something else, or
> 2/ add the parameters (with default values nullptr and 0) to all draw
> functions
> 3/ seeing that the new draw() method is actually only implemented for
> InsetMathChar (I assume that it is for text in math), decide that polluting
> the Inset class with that is not a good idea and just create an ad-hoc
> method that is explicitly called in MathRow::draw.
> 
> I think that 3/ is the best solution, but I'll let Koji decide.

Sounds good.

> > src/mathed/InsetMath.h:189:43: warning: ‘virtual lyx::InsetMathSubstack* 
> > lyx::InsetMath::asSubstackInset()’ was hidden [-Woverloaded-virtual=]
> >    189 |         virtual InsetMathSubstack       * asSubstackInset()       
> > { return nullptr; }
> >        |                                           ^~~~~~~~~~~~~~~
> > src/mathed/InsetMathSubstack.h:32:35: note:   by ‘virtual const 
> > lyx::InsetMathSubstack* lyx::InsetMathSubstack::asSubstackInset() const’
> >     32 |         InsetMathSubstack const * asSubstackInset() const override 
> > { return this; }
> >        |                                   ^~~~~~~~~~~~~~~
> 
> This is fixed in master now. I could as well have removed the methods, they
> are not in use.
> 
> > src/mathed/InsetMathHull.h:135:14: warning: ‘virtual void 
> > lyx::InsetMathHull::write(std::ostream&) const’ was hidden 
> > [-Woverloaded-virtual=]
> >    135 |         void write(std::ostream & os) const override;
> >        |              ^~~~~
> > src/mathed/InsetMathPar.h:36:14: note:   by ‘virtual void 
> > lyx::InsetMathPar::write(lyx::TeXMathStream&) const’
> >     36 |         void write(TeXMathStream & os) const override;
> >        |              ^~~~~
> 
> For this one, I think that the solution is to rename the second method. I'll
> do that.

Thank you for taking a look at the warnings. I don't imagine it's fun
work :)

Scott

Attachment: signature.asc
Description: PGP signature

-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
https://lists.lyx.org/mailman/listinfo/lyx-devel

Reply via email to