Uploaded image for project: 'ROOT'
  1. ROOT
  2. ROOT-9570

TTreeReaderArray<bool> silently returns wrong results when reading a vector<bool>

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Critical
    • Resolution: Fixed
    • 6.16/00, 6.14/06
    • None
    • None
    • None
    • any

    Description

      Minimal reproducer:

      #include <TFile.h>
      #include <TTree.h>
      #include <TTreeReader.h>
      #include <TTreeReaderArray.h>
      #include <vector>
      #include <iostream>
       
      int main()
      {
         using vbool_t = std::vector<bool>;
       
         TFile f("f.root", "recreate");
         TTree t("t", "t");
         vbool_t v{true, false};
         t.Branch("v", &v);
         t.Fill();
         t.Write();
         f.Close();
       
         TFile f2("f.root");
         TTreeReader r("t", &f2);
       
         TTreeReaderArray<bool> rv(r, "v");
       
         r.Next();
       
         // prints false false instead of true false
         for (auto e : rv)
            std::cout << std::boolalpha << e << std::endl;
       
         return 0;
      }
      

      Attachments

        Issue Links

          Activity

            People

              dpiparo Danilo Piparo
              eguiraud Enrico Guiraud
              Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Actual End: