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

Fix double to long double clang 10.0 diagnostic. #31

Closed
wants to merge 1 commit into from

Conversation

jaykrell
Copy link

@jaykrell jaykrell commented Dec 9, 2020

.../safeint.hpp.original:5868:27: error: implicit conversion increases floating-point precision: 'double' to 'long double' [-Werror,-Wdouble-promotion]
long double val = 0.0;

We could do this:

#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdouble-promotion"
#endif

...

#ifdef __clang__
#pragma clang diagnostic pop
#endif

Or add L suffix, which is safe.

.../safeint.hpp.original:5868:27: error: implicit conversion increases floating-point precision: 'double' to 'long double' [-Werror,-Wdouble-promotion]
        long double val = 0.0;
Either:

We could do this:

ifdef __clang__
pragma clang diagnostic push
pragma clang diagnostic ignored "-Wdouble-promotion"
endif

...

ifdef __clang__
pragma clang diagnostic pop
endif

Or add L suffix, which seems quite safe.

Most targets have long double the same format as double, and converting 0 is lossless.
@jaykrell jaykrell changed the title Fix double to long double clang 10.0 warning. Fix double to long double clang 10.0 diagnostic. Dec 9, 2020
@dcleblanc
Copy link
Owner

Pushed fix into use_c_headers branch.

@dcleblanc dcleblanc closed this Dec 9, 2020
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.

None yet

2 participants