1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-19 08:49:35 +01:00

Merge pull request #14179 from NixOS/backport-14154-to-2.31-maintenance

[Backport 2.31-maintenance] treewide: Remove toView() because it leads to segfaults when compiled…
This commit is contained in:
internal-nix-ci[bot] 2025-10-07 22:15:04 +00:00 committed by GitHub
commit 66f6ad1292
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 16 additions and 38 deletions

View file

@ -12,11 +12,6 @@
namespace nix {
/*
* workaround for unavailable view() method (C++20) of std::ostringstream under MacOS with clang-16
*/
std::string_view toView(const std::ostringstream & os);
/**
* String tokenizer.
*

View file

@ -121,7 +121,7 @@ public:
std::ostringstream oss;
showErrorInfo(oss, ei, loggerSettings.showTrace.get());
log(ei.level, toView(oss));
log(ei.level, oss.view());
}
void startActivity(

View file

@ -8,23 +8,6 @@
namespace nix {
struct view_stringbuf : public std::stringbuf
{
inline std::string_view toView()
{
auto begin = pbase();
return {begin, begin + pubseekoff(0, std::ios_base::cur, std::ios_base::out)};
}
};
__attribute__((no_sanitize("undefined"))) std::string_view toView(const std::ostringstream & os)
{
/* Downcasting like this is very much undefined behavior, so we disable
UBSAN for this function. */
auto buf = static_cast<view_stringbuf *>(os.rdbuf());
return buf->toView();
}
template std::list<std::string> tokenizeString(std::string_view s, std::string_view separators);
template StringSet tokenizeString(std::string_view s, std::string_view separators);
template std::vector<std::string> tokenizeString(std::string_view s, std::string_view separators);