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:
commit
66f6ad1292
13 changed files with 16 additions and 38 deletions
|
|
@ -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.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue