[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 15:32:22 PDT 2022


ddcc added inline comments.


================
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); }
----------------
ddcc wrote:
> 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); }
>                                                                                                     ~~~~~~ ^~~~~~~~~~~~~~~~~~~~~
> ```
I'm not quite sure whats going on here, I get a bunch of these even with my changes:
```
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); }
                                                                                                          ~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
warning: implicit conversion increases floating-point precision: 'float' to 'double' [-Wdouble-promotion]
inline _LIBCPP_INLINE_VISIBILITY float       hypot(       float __x,       float __y,       float __z ) { return sqrt(__x*__x + __y*__y + __z*__z); }
```


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