[libcxx-commits] [libcxx] [libc++][hardening] Categorize more assertions. (PR #75918)
Mark de Wever via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Dec 22 12:11:22 PST 2023
================
@@ -915,7 +915,10 @@ public:
return __bc != 0 ? (float)size() / __bc : 0.f;
}
_LIBCPP_HIDE_FROM_ABI void max_load_factor(float __mlf) _NOEXCEPT {
- _LIBCPP_ASSERT_UNCATEGORIZED(__mlf > 0, "unordered container::max_load_factor(lf) called with lf <= 0");
+ // While passing a non-positive load factor is undefined behavior, in practice the result will be benign (the
+ // call will be equivalent to `max_load_factor(load_factor())`, which is also the case for passing a valid value
+ // less than the current `load_factor`).
+ _LIBCPP_ASSERT_PEDANTIC(__mlf > 0, "unordered container::max_load_factor(lf) called with lf <= 0");
max_load_factor() = std::max(__mlf, load_factor());
----------------
mordante wrote:
Not really for this patch, but should we add an assert the value is not INF or NAN?
https://github.com/llvm/llvm-project/pull/75918
More information about the libcxx-commits
mailing list