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

Add workaround for libc++ incomplete from_chars(). #922

Merged
merged 1 commit into from
Aug 12, 2024

Conversation

atgeirr
Copy link
Member

@atgeirr atgeirr commented Aug 12, 2024

Float version not included in current version of libc++(15).

@atgeirr
Copy link
Member Author

atgeirr commented Aug 12, 2024

jenkins build this please

Comment on lines 934 to 936
// Floating point workaround.
char* end_ptr = nullptr;
defaultValue = std::strtod(defVal.c_str(), &end_ptr);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tiny simplification: It's okay to call strtod() as

defaultValue = std::strtod(defVal.c_str(), nullptr);

in this case.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Float version not included in current version (15).
@atgeirr atgeirr force-pushed the from_char-workaround branch from 89503c1 to 2ad332e Compare August 12, 2024 11:32
@atgeirr
Copy link
Member Author

atgeirr commented Aug 12, 2024

jenkins build this please

Copy link
Member

@bska bska left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for the updates. I'll merge into master.

@bska bska merged commit ba06db2 into OPM:master Aug 12, 2024
1 check passed
@atgeirr atgeirr deleted the from_char-workaround branch August 13, 2024 07:07
bska added a commit to bska/opm-models that referenced this pull request Aug 15, 2024
This commit broadens the scope of commit 2ad332e (PR OPM#922) to
apply to all compilers/libraries, not just Clang/libc++.  While
hopefully a transient situation, this enables building the parameter
system with GCC versions prior to GCC 11.  We expect to require
version 11 in the not too distant future, though.  At that point we
should revert this commit.
bska added a commit to bska/opm-models that referenced this pull request Aug 15, 2024
This commit broadens the scope of commit 2ad332e (PR OPM#922) to
apply to all compilers/libraries, not just Clang/libc++, which do
not have support for floating-point types in std::from_chars().
While hopefully a transient situation, this enables building the
parameter system with GCC versions prior to GCC 11.  We expect to
require version 11 in the not too distant future, though.  At that
point we should revert this commit.

We use a configure-time feature test of the compiler (CMake command
'try_compile') to detect whether or not the compiler supports
floating-point overloads of std::from_chars() and emit the result to
config.h as the new preprocessor symbol

    HAVE_FLOATING_POINT_FROM_CHARS

We use std::strtod() as the fall-back alternative for floating point
conversion if this symbol is defined to false (zero).
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

Successfully merging this pull request may close these issues.

3 participants