Skip to content

Fix all warnings on Linux #227

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

Conversation

hungptit
Copy link

@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
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