Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible compatibility issue with MPFR 4.2.1 #24

Open
gauravharsha opened this issue Nov 27, 2023 · 3 comments
Open

Possible compatibility issue with MPFR 4.2.1 #24

gauravharsha opened this issue Nov 27, 2023 · 3 comments

Comments

@gauravharsha
Copy link

gauravharsha commented Nov 27, 2023

This rudimentary code uses mpreal.h and MPFR libraries for C++. When compiling with

  • gcc-11.2.0, and
  • mpfr 3.1.4,

it works perfectly fine.
But after updating my libraries to

  • gcc-13 / clang-15, and
  • mpfr-4.2.1,

the compiler raises multiple errors related to, I believe, method inheritance.
For instance, the Clang 15 and MPFR-4.2.1 combo raises some of the following errors (among other similar ones):

  1. Dividing two multi-precision templated variables raises the compile-time error
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/complex:706:63: error: no matching function for call to '__constexpr_fabs'
  1. In other places, a division leads to the error
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:607:12: error: no matching function for call to 'isinf'

It is not unlikely that there are problems with the code itself, but the sudden breakdown of the attached code after updating the mpfr library makes me think there could be some incompatibilities introduced in the update. I would appreciate any valuable feedback.

PS: The link appears to be broken. I will instead try to share a simple example.

@advanpix
Copy link
Owner

Recently introduced C++23 features seem to cause these errors. Please compile the code in C++11 or similar mode.

@gauravharsha
Copy link
Author

I am using --std=c++11 in compile flags (or equivalently, using set(CMAKE_CXX_STANDARD 11) in my CMakeLists.txt file. However, the error persists.
As promised, here is a sample code:

#include <iostream>
#include <complex>
#include <gmpxx.h>
#include <mpreal.h>


using namespace mpfr;

int main(int argc, char * argv[]) {
  // Set precision
  mpreal::set_default_prec(128);
  // define two complex numbers
  std::complex<mpreal> a {1.0, 0.0};
  std::complex<mpreal> b {0.0, 1.0};
  // divide a by b
  std::complex<mpreal> c;
  c = a / b;
  std::cout << "a / b = " << c;
  return 0;
}

The corresponding CMakeLists.txt file is:

cmake_minimum_required(VERSION 3.11)
project(test_mpreal)

set(CMAKE_CXX_STANDARD 11)
#set (CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}")

set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)

find_package(GMP REQUIRED)
find_package(MPFR REQUIRED)

INCLUDE_DIRECTORIES(
        "${GMP_INCLUDES}"
        "${CMAKE_SOURCE_DIR}"
)

add_executable(test_mpreal main.cpp)
target_link_libraries(test_mpreal ${MPFR_LIBRARIES} ${GMPXX_LIBRARIES} ${GMP_LIBRARIES})
target_link_libraries(test_mpreal ${MPFR_LIBRARIES} ${GMPXX_LIBRARIES} ${GMP_LIBRARIES})

The output from cmake is:

-- The C compiler identification is AppleClang 15.0.0.15000040
-- The CXX compiler identification is AppleClang 15.0.0.15000040
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found GMP: /usr/local/include
-- Found MPFR: /usr/local/include (Required is at least version "1.0.0")
-- GMPXX_INCLUDES=/usr/local/include
-- Configuring done (2.5s)
-- Generating done (0.0s)

Library versions:

  • MPFR - 4.2.1
  • GMP - 6.3.0

Perhaps I'm missing something obvious here? The code compiled with older MPFR libraries, but does not do so after recent updates.

@cielavenir
Copy link

I (jfyi my company bought mpreal license) had a similar problem but my issue was my mpreal revision was before 269a037 . After updating I don't see such error.

I wonder if gauravharsha's mpreal revision was old.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants