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

RDataFrame Sum gets confused by std::string

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Medium
    • Resolution: Fixed
    • Affects Version/s: master
    • Fix Version/s: 6.16/00, 6.14/06
    • Component/s: None
    • Labels:
      None
    • Environment:

      ROOT master [9f9ea8c] on arch Linux, gcc 8.1.1

      Description

      Here is a reproducer macro:

      void test() {
         auto rdf = ROOT::RDF::MakeCsvDataFrame("test.csv");
         // The following line gives an error
         std::string oneline = *(rdf.Sum<std::string>("fstring"));
         // The following line works
         std::string oneline = *(rdf.Reduce([](std::string a, std::string b) {return a+b;}, "fstring"));
         std::cout << oneline << std::endl;
      }
      

      The rdf.Sum() line produces

      In file included from input_line_10:1:
      /home/jakob/Documents/CERN/ROOT/forest/build-git/test.C:3:16: error: no viable conversion from 'char' to 'std::string' (aka 'basic_string<char>')
         std::string oneline = *(rdf.Sum<std::string>("fstring"));
                     ^         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      /usr/lib/gcc/x86_64-pc-linux-gnu/8.1.1/../../../../include/c++/8.1.1/bits/basic_string.h:509:7: note: candidate constructor not viable: no known conversion from 'char' to 'const char *' for 1st argument; take the address of the argument with &
            basic_string(const _CharT* __s, const _Alloc& __a = _Alloc())
            ^
      /usr/lib/gcc/x86_64-pc-linux-gnu/8.1.1/../../../../include/c++/8.1.1/bits/basic_string.h:437:7: note: candidate constructor not viable: no known conversion from 'char' to 'const std::__cxx11::basic_string<char> &' for 1st argument
            basic_string(const basic_string& __str)
            ^
      /usr/lib/gcc/x86_64-pc-linux-gnu/8.1.1/../../../../include/c++/8.1.1/bits/basic_string.h:531:7: note: candidate constructor not viable: no known conversion from 'char' to 'std::__cxx11::basic_string<char> &&' for 1st argument
            basic_string(basic_string&& __str) noexcept
            ^
      /usr/lib/gcc/x86_64-pc-linux-gnu/8.1.1/../../../../include/c++/8.1.1/bits/basic_string.h:558:7: note: candidate constructor not viable: no known conversion from 'char' to 'initializer_list<char>' for 1st argument
            basic_string(initializer_list<_CharT> __l, const _Alloc& __a = _Alloc())
      

      And the corresponding CSV file is

      fstring
      "one"
      "line"
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              eguiraud Enrico Guiraud
              Reporter:
              jblomer Jakob Blomer
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Actual Start:
                Actual End: