Abseil StrCat example results in std::bad_alloc

  abseil, c++, cmake, conan, strcat

I tried to use abseil’s string library, but already the simple example does not run and fails with terminate called after throwing an instance of 'std::bad_alloc'.

The snippet I use

#include "absl/strings/str_cat.h"
#include "fmt/core.h"

int main(){
    auto s1 = absl::StrCat("A string ", " another string", "yet another string");
    fmt::print( "{}n", s1);
}

I use Abseil 20200923.2 with conan/cmake. I tried gcc 10.1 and clang 11, both with the same result. How can I make this code run?

Source: Windows Questions C++

LEAVE A COMMENT