[libcxx-commits] [PATCH] D131929: [libcxx] Resolve warnings for Wimplicit-float-conversion, Wmacro-redefined, Wzero-as-null-pointer-constant, Wsign-conversion
Dominic Chen via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Aug 16 14:48:28 PDT 2022
ddcc marked an inline comment as not done.
ddcc added a comment.
In D131929#3727098 <https://reviews.llvm.org/D131929#3727098>, @ldionne wrote:
> Thanks for the patch!
>
>> These warnings should be enabled in the test suite to avoid regressions.
>
> @ddcc You can do that by adding them in `libcxx/utils/libcxx/test/params.py`.
Will do.
================
Comment at: libcxx/include/atomic:2694
+#undef ATOMIC_FLAG_INIT
#define ATOMIC_FLAG_INIT {false}
----------------
ldionne wrote:
> Is this because `ATOMIC_FLAG_INIT` was already defined by the C Library?
Yeah, not sure whether we want to unconditionally undef or do ifdef here.
================
Comment at: libcxx/include/cmath:534
inline _LIBCPP_INLINE_VISIBILITY float hypot( float __x, float __y, float __z ) { return sqrt(__x*__x + __y*__y + __z*__z); }
-inline _LIBCPP_INLINE_VISIBILITY double hypot( double __x, double __y, double __z ) { return sqrt(__x*__x + __y*__y + __z*__z); }
-inline _LIBCPP_INLINE_VISIBILITY long double hypot( long double __x, long double __y, long double __z ) { return sqrt(__x*__x + __y*__y + __z*__z); }
+inline _LIBCPP_INLINE_VISIBILITY double hypot( double __x, double __y, double __z ) { return sqrtf(__x*__x + __y*__y + __z*__z); }
+inline _LIBCPP_INLINE_VISIBILITY long double hypot( long double __x, long double __y, long double __z ) { return sqrtl(__x*__x + __y*__y + __z*__z); }
----------------
philnik wrote:
> What exactly is the problem here? `sqrt` has overloads for `float`, `double` and `long double`.
```
warning: implicit conversion loses floating-point precision: 'double' to 'float' [-Wimplicit-float-conversion]
inline _LIBCPP_INLINE_VISIBILITY float hypot( float x, float y, float z ) { return sqrt(x*x + y*y + z*z); }
~~~~~~ ^~~~~~~~~~~~~~~~~~~~~
```
================
Comment at: libcxx/include/string_view:288
typedef ptrdiff_t difference_type;
- static _LIBCPP_CONSTEXPR const size_type npos = -1; // size_type(-1);
+ static _LIBCPP_CONSTEXPR const size_type npos = ~static_cast<size_type>(0U); // size_type(-1);
----------------
philnik wrote:
> Maybe use numeric_limits here instead?
Will do.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D131929/new/
https://reviews.llvm.org/D131929
More information about the libcxx-commits
mailing list