Skip to content

Commit

Permalink
check lifetimes of TStringBuf constructed from TString without taking…
Browse files Browse the repository at this point in the history
… into account copy-on-write semantics

`TString` is a copy-on-write type, which means that in some cases the valid lifetime of its data might extend beyond the lifetime of an individual `TString` (if it was copied).

However, there are practically no cases where this behaviour is appropriate, and leaving around an "owning" `TString` is undesirable.

Due to this behaviour we have previously refrained from enabling `[[clang::lifetimebound]]` for `TStringBuf` constructors, because some cases of view construction from a temporary `TString` were in fact valid.

This commit enables the check, as all existing related bugs in Arcadia have been fixed. Please see the related ticket and the announcement on Этушка (link will be in the post-commit comments) for more information.
commit_hash:b2b6831ac3106a4e76064b85ec2d748b415ed67c
  • Loading branch information
ubyte committed Mar 11, 2025
1 parent 23f480b commit ca2be06
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion util/generic/strbuf.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class TBasicStringBuf: public std::basic_string_view<TCharType>,
}

template <typename T>
inline TBasicStringBuf(const TBasicString<TCharType, T>& str Y_STRING_LIFETIME_BOUND) noexcept
inline TBasicStringBuf(const TBasicString<TCharType, T>& str Y_LIFETIME_BOUND) noexcept
: TStringView(str.data(), str.size())
{
}
Expand Down

0 comments on commit ca2be06

Please sign in to comment.