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

**URL:** <https://root-forum.cern.ch/t/warning-this-pointer-is-null-in-roofit-histfactory-src-configparser-cxx/46768>\
**Category:** ROOT\
**Tags:** bug\
**Created:** [September 9, 2021, 3:52pm UTC](https://root-forum.cern.ch/t/warning-this-pointer-is-null-in-roofit-histfactory-src-configparser-cxx/46768 "2021-09-09T15:52:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ivankp](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ivankp/32/25365_2.png) [@ivankp](https://root-forum.cern.ch/u/ivankp)\
**Post date:** [September 9, 2021, 3:52pm UTC](https://root-forum.cern.ch/t/warning-this-pointer-is-null-in-roofit-histfactory-src-configparser-cxx/46768/1 "2021-09-09T15:52:21Z")

</div>

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
/msu/data/t3work3/ivanp/build/gcc11/root-6.24.06/roofit/histfactory/src/ConfigParser.cxx: 
  In member function 'RooStats::HistFactory::Measurement 
  RooStats::HistFactory::ConfigParser::CreateMeasurementFromDriverNode(TXMLNode*)':
  /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.

---

<div class="post-metadata">

**Author:** ![jalopezg](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/jalopezg/32/25844_2.png) [@jalopezg](https://root-forum.cern.ch/u/jalopezg)\
**Post date:** [September 9, 2021, 11:14pm UTC](https://root-forum.cern.ch/t/warning-this-pointer-is-null-in-roofit-histfactory-src-configparser-cxx/46768/2 "2021-09-09T23:14:27Z")

</div>

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:

> [@ivankp](#):
>
> `( curAttr = dynamic_cast< TXMLAttr* >( attribIt() ) )`

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.

Cheers,  
J.

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [September 23, 2021, 11:14pm UTC](https://root-forum.cern.ch/t/warning-this-pointer-is-null-in-roofit-histfactory-src-configparser-cxx/46768/3 "2021-09-23T23:14:57Z")

</div>

Closed on September 23, 2021, 11:14pm UTC

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