Warning: 'this' pointer is null in roofit/histfactory/src/ConfigParser.cxx

I’m compiling root-6.24.06 from source with gcc-11.2.0 and got the following warning:

[ 77%] Building CXX object roofit/histfactory/CMakeFiles/HistFactory.dir/src/ConfigParser.cxx.o
  In member function 'RooStats::HistFactory::Measurement 
  /msu/data/t3work3/ivanp/build/gcc11/root-6.24.06/roofit/histfactory/src/ConfigParser.cxx:376:41: warning: 'this' pointer is null [-Wnonnull]
  376 |                     << curAttr->GetName() << std::endl;

Taking a quick look at ConfigParser.cxx reveals that there’s indeed a bug. curAttr is defined on line 281, followed immediately by a while loop with the following condition:

TXMLAttr* curAttr = 0;
while( ( curAttr = dynamic_cast< TXMLAttr* >( attribIt() ) ) != 0 ) { . . . }

Clearly, before and after the loop curAttr is null.

The culprit line is located not far below the end of the while loop on line 376, where the member function is called curAttr->GetName(). Clearly, at this point curAttr is null.

Hi @ivankp,

Thanks for taking the time to look at the sources! In this case, curAttr is assigned as part of the conditional expression of the while statement as follows:

I don’t think the problem is curAttr, but probably the call to operator<<. I will invite @jonas and @moneta to this thread, as they are the Roofit experts. After their verdict, maybe we can consider creating an issue on GitHub.


This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.