Skip to content

Fix all warnings on Linux#227

Closed
hungptit wants to merge 1 commit into
Genivia:masterfrom
hungptit:hd-fix-warnings
Closed

Fix all warnings on Linux#227
hungptit wants to merge 1 commit into
Genivia:masterfrom
hungptit:hd-fix-warnings

Conversation

@hungptit
Copy link
Copy Markdown

@hungptit hungptit commented Apr 7, 2025

Problem

I got these warnings when compiling re-flex on Linux (gcc-14.2.1).

make[2]: Entering directory '/home/hungptit/working/ioutils/.local/build/reflex/tests'
g++ -DHAVE_CONFIG_H -I. -I/home/hungptit/working/ioutils/_deps/reflex-src/tests -I..  -I/home/hungptit/working/ioutils/_deps/reflex-src/include   -Wall -Wextra -Wunused -O2 -MT rtest-rtest.o -MD -MP -MF .deps/rtes
t-rtest.Tpo -c -o rtest-rtest.o `test -f 'rtest.cpp' || echo '/home/hungptit/working/ioutils/_deps/reflex-src/tests/'`rtest.cpp
In file included from /home/hungptit/working/ioutils/_deps/reflex-src/tests/rtest.cpp:7:
/home/hungptit/working/ioutils/_deps/reflex-src/include/reflex/matcher.h:112:20: warning: ‘virtual reflex::Matcher& reflex::Matcher::operator=(const reflex::Matcher&)’ was hidden [-Woverloaded-virtual=]
  112 |   virtual Matcher& operator=(const Matcher& matcher) ///< matcher to copy
      |                    ^~~~~~~~               
/home/hungptit/working/ioutils/_deps/reflex-src/tests/rtest.cpp:31:7: note:   by ‘WrappedMatcher::operator=’
   31 | class WrappedMatcher : public Matcher {                                                                                                                                                                      
      |       ^~~~~~~~~~~~~~                                                                              
In file included from /home/hungptit/working/ioutils/_deps/reflex-src/include/reflex/matcher.h:40:                                                                                                                   
/home/hungptit/working/ioutils/_deps/reflex-src/include/reflex/absmatcher.h:1694:27: warning: ‘reflex::PatternMatcher<P>& reflex::PatternMatcher<P>::operator=(const reflex::PatternMatcher<P>&) [with P = reflex::Pa
ttern]’ was hidden [-Woverloaded-virtual=]                                                                
 1694 |   virtual PatternMatcher& operator=(const PatternMatcher& matcher) ///< matcher with pattern to use (pattern may be shared)
      |                           ^~~~~~~~                                                                
/home/hungptit/working/ioutils/_deps/reflex-src/tests/rtest.cpp:31:7: note:   by ‘WrappedMatcher::operator=’
   31 | class WrappedMatcher : public Matcher {                                                           
      |       ^~~~~~~~~~~~~~                                                   

Solution

Remove the virtual keywords in related template classes.

@genivia-inc
Copy link
Copy Markdown
Member

genivia-inc commented Apr 25, 2025

Thank you for your feedback. I am not sure this is the right thing to do. What may cause the warning is located in abslexer.h, which can be updated by adding this at line 74 to the class Matcher : public M scope:

    /// Assign a matcher, the underlying pattern object is shared (not deep copied).
    virtual Matcher& operator=(const Matcher& matcher)
    {
      M::operator=(matcher);
      lexer_ = matcher.lexer_;
      return *this;
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants