From: Jonathan Wakely Date: Fri, 22 Mar 2019 16:45:48 +0000 (+0000) Subject: Avoid -Wconversion warnings when -Wsystem-headers is used X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=eca5f9254bbb06364a0fc91fdf7bde820bd8d225;p=gcc.git Avoid -Wconversion warnings when -Wsystem-headers is used * include/bits/stl_algobase.h (__lg): Do arithmetic on type int to avoid -Wconversion warnings. From-SVN: r269876 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index c8672263a6f..2a3021a2f66 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,8 @@ +2019-03-22 Jonathan Wakely + + * include/bits/stl_algobase.h (__lg): Do arithmetic on type int to + avoid -Wconversion warnings. + 2019-03-21 Thomas Rodgers * include/Makefile.am (std_header): Add ${std_srcdir}/execution. diff --git a/libstdc++-v3/include/bits/stl_algobase.h b/libstdc++-v3/include/bits/stl_algobase.h index 2b69e658fe8..3b1139401ee 100644 --- a/libstdc++-v3/include/bits/stl_algobase.h +++ b/libstdc++-v3/include/bits/stl_algobase.h @@ -1018,27 +1018,27 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // Precondition: __n > 0. inline _GLIBCXX_CONSTEXPR int __lg(int __n) - { return sizeof(int) * __CHAR_BIT__ - 1 - __builtin_clz(__n); } + { return (int)sizeof(int) * __CHAR_BIT__ - 1 - __builtin_clz(__n); } inline _GLIBCXX_CONSTEXPR unsigned __lg(unsigned __n) - { return sizeof(int) * __CHAR_BIT__ - 1 - __builtin_clz(__n); } + { return (int)sizeof(int) * __CHAR_BIT__ - 1 - __builtin_clz(__n); } inline _GLIBCXX_CONSTEXPR long __lg(long __n) - { return sizeof(long) * __CHAR_BIT__ - 1 - __builtin_clzl(__n); } + { return (int)sizeof(long) * __CHAR_BIT__ - 1 - __builtin_clzl(__n); } inline _GLIBCXX_CONSTEXPR unsigned long __lg(unsigned long __n) - { return sizeof(long) * __CHAR_BIT__ - 1 - __builtin_clzl(__n); } + { return (int)sizeof(long) * __CHAR_BIT__ - 1 - __builtin_clzl(__n); } inline _GLIBCXX_CONSTEXPR long long __lg(long long __n) - { return sizeof(long long) * __CHAR_BIT__ - 1 - __builtin_clzll(__n); } + { return (int)sizeof(long long) * __CHAR_BIT__ - 1 - __builtin_clzll(__n); } inline _GLIBCXX_CONSTEXPR unsigned long long __lg(unsigned long long __n) - { return sizeof(long long) * __CHAR_BIT__ - 1 - __builtin_clzll(__n); } + { return (int)sizeof(long long) * __CHAR_BIT__ - 1 - __builtin_clzll(__n); } _GLIBCXX_BEGIN_NAMESPACE_ALGO