[MDEV-21050] warning: 'finite' is deprecated: first deprecated in macOS 10.9 Created: 2019-11-11  Updated: 2019-11-19  Resolved: 2019-11-19

Status: Closed
Project: MariaDB Server
Component/s: Compiling
Affects Version/s: 10.2
Fix Version/s: 10.2.30

Type: Bug Priority: Major
Reporter: Alexey Bychko (Inactive) Assignee: Vladislav Lesin
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Duplicate
duplicates MDEV-21082 isnan/isinf compilation errors, isfin... Closed

 Description   

/Users/abychko/GitHub/MariaDB/MariaDBEnterprise/sql/item_func.h:244:12: warning: 'finite' is deprecated: first deprecated in macOS 10.9 - Use
      `isfinite((double)x)` instead. [-Wdeprecated-declarations]
    return isfinite(value) ? value : raise_float_overflow();
           ^
/Users/abychko/GitHub/MariaDB/MariaDBEnterprise/include/my_global.h:820:21: note: expanded from macro 'isfinite'
#define isfinite(x) finite(x)
                    ^
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/math.h:749:12: note: 'finite' has been explicitly marked deprecated here
extern int finite(double)



 Comments   
Comment by Alexey Bychko (Inactive) [ 2019-11-13 ]

#ifndef isfinite
#ifdef HAVE_FINITE
#define isfinite(x) finite(x)
#else
#define finite(x) (1.0 / fabs(x) > 0.0)
#endif /* HAVE_FINITE */
#elif (__cplusplus >= 201103L)
#include <cmath>
static inline bool isfinite(double x) { return std::isfinite(x); }
#endif /* isfinite */

isfinite() is a macros in C99 and a function is c++ 11, so atm isfinite is always undefined. so, defines are not correct with c++11

Comment by Alexey Bychko (Inactive) [ 2019-11-13 ]

is may be required to make a fix in CS first, because that check for isfinite definition was added 11 years ago

Comment by Alexey Bychko (Inactive) [ 2019-11-13 ]

possible fix in my_global.h (requires additional checks)

#ifndef isfinite
# ifdef HAVE_STD_ISFINITE
#   define isfinite(x) std::isfinite(x)
# else
#   ifndef HAVE_ISFINITE
#     ifndef HAVE_FINITE
#       define finite(x) (1.0 / fabs(x) > 0.0)
#      endif  /* HAVE_FINITE */
#     define isfinite(x) finite((double)x)
#   endif /* HAVE_ISFINITE */
# endif /* HAVE_STD_ISFINITE */
#endif /* isfinite */

checks in config.h.cmake:

#cmakedefine HAVE_ISFINITE 1
#cmakedefine HAVE_STD_ISFINITE 1

checks in configure.cmake:

CHECK_SYMBOL_EXISTS(isfinite math.h HAVE_ISFINITE)
CHECK_CXX_SYMBOL_EXISTS(std::isfinite cmath HAVE_STD_ISFINITE)

Comment by Alexey Bychko (Inactive) [ 2019-11-15 ]

this fix removes a lot of garbage output during compilation on MacOS and makes the log readable

Generated at Thu Feb 08 09:04:13 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.