On Sun, 7 Jan 2024 at 12:57, François Dumont <frs.dum...@gmail.com> wrote: > > Hi > > While working on the patch to use the cxx11 abi in gnu version namespace > mode I got a small problem with this missing constructor. I'm not sure > that the main patch will be integrated in gcc 14 so I think it is better > if I propose this patch independently. > > libstdc++: Add __cow_string constructor from C string > > The __cow_string is instantiated from a C string in > cow-stdexcept.cc. At the moment > the constructor from std::string is being used with the drawback of > an intermediate > potential allocation/deallocation and copy. With the C string > constructor we bypass > all those operations.
But in that file, the std::string is the COW string, which means that when we construct a std::string and copy it, it's cheap. It's just a reference count increment/decrement. There should be no additional allocation or deallocation. Am I missing something? > > libstdc++-v3/ChangeLog: > > * include/std/stdexcept (__cow_string(const char*)): New > definition. > * src/c++11/cow-stdexcept.cc (__cow_string(const char*)): > New definition and > declaration. > > Tested under Linux x64, ok to commit ? > > François >