diff --git a/roottest/root/io/evolution/versions/execROOT14491.cxx b/roottest/root/io/evolution/versions/execROOT14491.cxx new file mode 100644 index 0000000000000..7d6bb84806bab --- /dev/null +++ b/roottest/root/io/evolution/versions/execROOT14491.cxx @@ -0,0 +1,71 @@ +// See https://github.com/root-project/root/issues/14491#issuecomment-1917587621 +#ifndef SIMPLEREAD +#define SIMPLEREAD + +#include +#include +#include "Rtypes.h" + +template +struct Wrapper +{ + bool present = true; + T obj; +}; + +struct MatchedCSCSegment +{ + float someValue = 0.0; + + MatchedCSCSegment(float in = 0.0) : someValue{in} {} + + // The simple update failed if the class version was not set. + // ClassDef(MatchedCSCSegment, 5); +}; + +struct CSCSegment +{ + float someValue; + + operator MatchedCSCSegment() + { + return MatchedCSCSegment{someValue}; + } + + std::vector theDuplicateSegments; + + // ClassDef(CSCSegment, 4); +}; + +#ifdef __ROOTCLING__ +#pragma link C++ class MatchedCSCSegment+; +#pragma link C++ class CSCSegment+; +#pragma link C++ class Wrapper>+; +#pragma read sourceClass="CSCSegment" targetClass="MatchedCSCSegment" +#endif + +#endif + +#include "TFile.h" +#include "TTree.h" + +void test(TTree *t, const char *bname) +{ + std::string formula = bname; + formula += ".obj.theDuplicateSegments@.size()"; + t->Scan(formula.c_str()); +} + +int execROOT14491() +{ + auto file = TFile::Open("oldfile14491.root", "READ"); + auto t = file->Get("t"); + t->LoadTree(0); + // gDebug = 7; + test(t, "seg_split"); + // gDebug = 0; + test(t, "seg_unsplit"); + file->Close(); + delete file; + return 0; +} diff --git a/roottest/root/io/evolution/versions/execROOT14491.ref b/roottest/root/io/evolution/versions/execROOT14491.ref new file mode 100644 index 0000000000000..d3760d120c73d --- /dev/null +++ b/roottest/root/io/evolution/versions/execROOT14491.ref @@ -0,0 +1,13 @@ + +Processing execROOT14491.cxx+... +*********************************** +* Row * Instance * seg_split * +*********************************** +* 0 * 0 * 0 * +*********************************** +*********************************** +* Row * Instance * seg_unspl * +*********************************** +* 0 * 0 * 1 * +*********************************** +(int) 0 diff --git a/roottest/root/io/evolution/versions/oldfile14491.root b/roottest/root/io/evolution/versions/oldfile14491.root new file mode 100644 index 0000000000000..287dae45f0e61 Binary files /dev/null and b/roottest/root/io/evolution/versions/oldfile14491.root differ