[llvm] [LLVM][ADT] Explicitly convert size_t values to SmallVector's size type (PR #77939)
Andrei Golubev via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 17 05:36:27 PST 2024
================
@@ -99,8 +99,9 @@ template <class Size_T> class SmallVectorBase {
///
/// This does not construct or destroy any elements in the vector.
void set_size(size_t N) {
- assert(N <= capacity());
- Size = N;
+ auto n = static_cast<Size_T>(N);
+ assert(n <= capacity());
----------------
andrey-golubev wrote:
I thought assert() is by definition debug-only (exception being if one explicitly sets `LLVM_ENABLE_ASSERTIONS`). do you think people use `assert()` via LLVM_ENABLE_ASSERTIONS in production?
https://github.com/llvm/llvm-project/pull/77939
More information about the llvm-commits
mailing list