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

Implicit conversion from string_view to TString breaks existing code

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Blocker
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 6.20/00
    • Component/s: None
    • Labels:
      None
    • Environment:

      LHCb nightlies against ROOT master

      Description

      This is what happens:

      lxplus780 ~ $ . /cvmfs/sft-nightlies.cern.ch/lcg/nightlies/dev3/Wed/ROOT/HEAD/x86_64-centos7-gcc9-opt/ROOT-env.sh 
      lxplus780 ~ $ root -b
         ------------------------------------------------------------------
        | Welcome to ROOT 6.19/01                        https://root.cern |
        | (c) 1995-2019, The ROOT Team; conception: R. Brun, F. Rademakers |
        | Built for linuxx8664gcc on Jan 15 2020, 03:29:00                 |
        | From heads/master@v6-19-01-2427-g97e62a0                         |
        | Try '.help', '.demo', '.license', '.credits', '.quit'/'.q'       |
         ------------------------------------------------------------------
       
      root [0] #include <TString.h>
      root [1] std::string_view a = "a";
      root [2] std::string b = "b";
      root [3] a == b
      ROOT_prompt_3:1:3: error: use of overloaded operator '==' is ambiguous (with operand types 'std::string_view' (aka 'basic_string_view<char>') and 'std::string' (aka 'basic_string<char>'))
      a == b
      ~ ^  ~
      /cvmfs/sft.cern.ch/lcg/releases/gcc/9.2.0-afc57/x86_64-centos7/bin/../lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../include/c++/9.2.0/string_view:479:5: note: candidate function [with _CharT = char, _Traits = std::char_traits<char>]
          operator==(basic_string_view<_CharT, _Traits> __x,
          ^
      /cvmfs/sft-nightlies.cern.ch/lcg/nightlies/dev3/Wed/ROOT/HEAD/x86_64-centos7-gcc9-opt/include/TEveUtil.h:99:6: note: candidate function
      bool operator==(const TString& t, const std::string& s);
           ^
      /cvmfs/sft-nightlies.cern.ch/lcg/nightlies/dev3/Wed/ROOT/HEAD/x86_64-centos7-gcc9-opt/include/TString.h:752:15: note: candidate function
      inline Bool_t operator==(const TString &s1, const TString &s2)
      

      As there's no automatic conversion from string_view to string, there should not be an automatic conversion from string_view to TString.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              pcanal Philippe Canal
              Reporter:
              clemenci Marco Clemencic
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: