Project

General

Profile

Bug #5144

Updated by Junxiao Shi about 3 years ago

The base class RegexMatcher [declares](https://github.com/named-data/ndn-cxx/blob/fe24bf84129d71569d13af918a394ccc9c56a999/ndn-cxx/util/regex/regex-matcher.hpp#L81) [declares](https://github.com/named-data/ndn-cxx/blob/master/ndn-cxx/util/regex/regex-matcher.hpp#L81) the pure virtual method compile(). Derived classes like NdnRegexTopMatcher override compile(). Furthermore, then [call](https://github.com/named-data/ndn-cxx/blob/fe24bf84129d71569d13af918a394ccc9c56a999/ndn-cxx/util/regex/regex-top-matcher.cpp#L40) [call](https://github.com/named-data/ndn-cxx/blob/master/ndn-cxx/util/regex/regex-top-matcher.cpp#L40) compile() in the constructor. 

 One of my code safety tools is complaining about this. Calling a virtual method from a constructor can have undefined results. As far as I can tell, RegexMatcher does not need to declare that compile() is a virtual method. No code calls it directly. As a test, I commented it out, and in the derived classes I removed the "override" tag from the compile() method. ./waf does not report any errors. 

 Do you agree that compile() does not need to be declared in the base class RegexMatcher? If so, then it can be removed to fix the warning about calling a virtual method from a constructor.

Back