GetPtr work differently when it is return from fuction (maybe a bug)

I also check the results of ClassName and Class_Name as

    cout << "Histo1D.ClassName:                 " << getTH1DFunc()->ClassName() << endl;
    cout << "Histo1D.Class_Name:                " << getTH1DFunc()->Class_Name() << endl;

    cout << "Func returned Histo1D.ClassName:   " << getTH1DPtrFunc()->ClassName() << endl;
    cout << "Func returned Histo1D.Class_Name:  " << getTH1DPtrFunc()->Class_Name() << endl;

The results are

Histo1D.ClassName:                 TH1D
Histo1D.Class_Name:                TH1D
Func returned Histo1D.ClassName:   TObject
Func returned Histo1D.Class_Name:  TH1D

It also confused me following the discussion about the ClassName and Class_Name in the https://root-forum.cern.ch/t/classname-vs-class-name/51479