aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorthegeorg <thegeorg@yandex-team.com>2024-11-21 11:57:38 +0300
committerthegeorg <thegeorg@yandex-team.com>2024-11-21 12:08:20 +0300
commit90a8f8cc3c8915e9573196a81d7bd33b598fcd77 (patch)
tree325d6e6a78e015eb8d46f5563367b709aba0818a
parented5b11df0064bcf6ef0d03aa0f1a34f4aa97851d (diff)
downloadydb-90a8f8cc3c8915e9573196a81d7bd33b598fcd77.tar.gz
contrib/libs/poco: Backport PR #2943 to fix -Wimplicit-const-int-float-conversion
Backport [PR #2943](https://github.com/pocoproject/poco/pull/2943) from poco upstream. commit_hash:5013b65cd3f7e719f6489c889c710eea3ad91537
-rw-r--r--contrib/libs/poco/Foundation/include/Poco/Dynamic/VarHolder.h26
1 files changed, 22 insertions, 4 deletions
diff --git a/contrib/libs/poco/Foundation/include/Poco/Dynamic/VarHolder.h b/contrib/libs/poco/Foundation/include/Poco/Dynamic/VarHolder.h
index 85af40f449..9a85a24aee 100644
--- a/contrib/libs/poco/Foundation/include/Poco/Dynamic/VarHolder.h
+++ b/contrib/libs/poco/Foundation/include/Poco/Dynamic/VarHolder.h
@@ -452,15 +452,33 @@ private:
template <typename F, typename T>
void checkUpperLimitFloat(const F& from) const
{
- if (from > std::numeric_limits<T>::max())
- throw RangeException("Value too large.");
+ if (std::is_floating_point<T>::value)
+ {
+ if (from > std::numeric_limits<T>::max())
+ throw RangeException("Value too large.");
+ }
+ else
+ {
+ // Avoid clang -Wimplicit-int-float-conversion warning with an explicit cast.
+ if (from > static_cast<F>(std::numeric_limits<T>::max()))
+ throw RangeException("Value too large.");
+ }
}
template <typename F, typename T>
void checkLowerLimitFloat(const F& from) const
{
- if (from < -std::numeric_limits<T>::max())
- throw RangeException("Value too small.");
+ if (std::is_floating_point<T>::value)
+ {
+ if (from < -std::numeric_limits<T>::max())
+ throw RangeException("Value too small.");
+ }
+ else
+ {
+ // Avoid clang -Wimplicit-int-float-conversion warning with an explicit cast.
+ if (from < static_cast<F>(std::numeric_limits<T>::min()))
+ throw RangeException("Value too small.");
+ }
}
template <typename F, typename T>