root
root copied to clipboard
Properly use `Copy(TObject &)` methods in `hist` classes
This is virtual method and can be overriden in derived classes. Therefore when such method used in copy constructor or assignment operator, one have to explicitly specify class which used.
Fixes #10919
Starting build on ROOT-debian10-i386/soversion, ROOT-performance-centos8-multicore/cxx17, ROOT-ubuntu18.04/nortcxxmod, ROOT-ubuntu2004/python3, mac1015/cxx17, mac11/cxx14, windows10/cxx14
How to customize builds
Build failed on ROOT-ubuntu18.04/nortcxxmod. Running on sft-ubuntu-1804-3.cern.ch:/build/workspace/root-pullrequests-build See console output.
Failing tests:
Build failed on ROOT-performance-centos8-multicore/cxx17. Running on olbdw-01.cern.ch:/data/sftnight/workspace/root-pullrequests-build See console output.
Failing tests:
Build failed on ROOT-ubuntu2004/python3. Running on root-ubuntu-2004-1.cern.ch:/home/sftnight/build/workspace/root-pullrequests-build See console output.
Failing tests:
Build failed on windows10/cxx14. Running on null:C:\build\workspace\root-pullrequests-build See console output.
Failing tests:
Build failed on ROOT-debian10-i386/soversion. Running on pcepsft11.dyndns.cern.ch:/home/sftnight/build/workspace/root-pullrequests-build See console output.
Failing tests:
Build failed on mac1015/cxx17. Running on macitois22.dyndns.cern.ch:/Users/sftnight/build/workspace/root-pullrequests-build See console output.
Failing tests:
Build failed on mac11/cxx14. Running on macphsft23.dyndns.cern.ch:/Users/sftnight/build/workspace/root-pullrequests-build See console output.
Failing tests:
If one want to keep usage of virtual Copy methods, in each such method one should check if source object type match this object - using dynamic cast. Otherwise it may produce segmentation violation.
In my mind, current implementation of copy constructors with using of virtual Copy methods is wrong and error prone.
Are you referring about a check that the final type of the source is the same final type pf the target, i.e. in this code below:
TH2D::TH2D(const TH2D &h2d) : TH2(), TArrayD()
{
((TH2D&)h2d).Copy(*this);
}
if this and 'h2dare actually the same final types (e.g. both TProfile histograms). This check is performed in theTProfile::Copy` function, see :
https://github.com/root-project/root/blob/master/hist/hist/src/TProfile.cxx#L422
This check is performed in theTProfile::Copy` function,
Such check must be introduced in all Copy methods in all classes.
To avoid such checks, I propose directly call method of appropriate class and do not use virtual interface.
I agree if one is able to call copy constructors only for the final classes and not for base ones. In the ROOT histogram design this is not the case, since we have classes as TProfile deriving from TH1D and not TH1.
When calling virtual Copy method in copy constructor - one never knows that exact happens.
User can define derived class from TH1D and provide own Copy implementation.
In such case TH1D th1 = user_th1; will leads to wrong results. TProfile is just example of that with existing ROOT classes.
Starting build on ROOT-debian10-i386/soversion, ROOT-performance-centos8-multicore/cxx17, ROOT-ubuntu18.04/nortcxxmod, ROOT-ubuntu2004/python3, mac1015/cxx17, mac11/cxx14, windows10/cxx14
How to customize builds
Build failed on ROOT-ubuntu18.04/nortcxxmod. Running on sft-ubuntu-1804-2.cern.ch:/build/workspace/root-pullrequests-build See console output.
Failing tests:
Build failed on ROOT-ubuntu2004/python3. Running on root-ubuntu-2004-1.cern.ch:/home/sftnight/build/workspace/root-pullrequests-build See console output.
Failing tests:
Build failed on ROOT-performance-centos8-multicore/cxx17. Running on olbdw-01.cern.ch:/data/sftnight/workspace/root-pullrequests-build See console output.
Failing tests:
Build failed on windows10/cxx14. Running on null:C:\build\workspace\root-pullrequests-build See console output.
Failing tests:
Build failed on ROOT-debian10-i386/soversion. Running on pcepsft11.dyndns.cern.ch:/home/sftnight/build/workspace/root-pullrequests-build See console output.
Failing tests:
Build failed on mac11/cxx14. Running on macphsft20.dyndns.cern.ch:/Users/sftnight/build/workspace/root-pullrequests-build See console output.
Failing tests:
I already prepare PR for root-test:
https://github.com/root-project/roottest/pull/884
I will merge it shortly after merging this PR
Build failed on mac1015/cxx17. Running on macitois22.dyndns.cern.ch:/Users/sftnight/build/workspace/root-pullrequests-build See console output.
Errors:
- [2022-08-17T18:47:03.012Z] CMake Error at /Volumes/HD2/build/workspace/root-pullrequests-build/rootspi/jenkins/root-build.cmake:1088 (message):