1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-05 12:21:48 +02:00

Merge pull request #12615 from xokdvium/ubsan-checks

flake: Enable UBSAN for checks
This commit is contained in:
Jörg Thalheim 2025-03-11 14:22:20 +01:00 committed by GitHub
commit 8e8edb5bf8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 36 additions and 6 deletions

View file

@ -17,8 +17,10 @@ struct view_stringbuf : public std::stringbuf
}
};
std::string_view toView(const std::ostringstream & os)
__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();
}