DavidSpickett wrote:
Is it a lifetime problem?
```
result.insert({"description", ERB.description.c_str()});
```
Inserts a KV into json::Object.
```
struct Object::KV {
ObjectKey K;
Value V;
};
```
```
inline std::pair<Object::iterator, bool> Object::insert(KV E) {
return try_emplace(std::move(E.K), std::move(E.V));
}
```
`std::move` of `const char*` just copies the pointer, but for a `std::string`
it would copy the memory (/transfer ownership of it). And on some platforms we
have reused the memory by the time it's encoded to JSON.
Not sure though because there's some laters of templates in the way. This is
the only `toJSON` in the file that uses `c_str` though and it would explain why
the API reproducer is fine.
If that makes sense to you, feel free to reland with that change. Otherwise
give me any more ideas and I'll continue to dig.
https://github.com/llvm/llvm-project/pull/165858
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits