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

Convert arguments to double in _GENERIC_MATH2_BASE #3253

Merged
merged 4 commits into from
Dec 6, 2022

Conversation

CaseyCarter
Copy link
Member

This template implements the "sufficient additional overloads" for two-argument <cmath> functions (atan2, hypot, pow, fmod, remainder, copysign, nextafter, fdim, fmax, and fmin) by calling either an intrinsic or a C library function either of which expects double arguments. We previously converted the arguments to _Common_float_type_t which is long double when at least one argument is long double, resulting in narrowing conversion warnings at /W4. We now convert the arguments to double instead of _Common_float_type_t.

Fixes #3246

This template implements the "sufficient additional overloads" for two-argument `<cmath>` functions (`atan2`, `hypot`, `pow`, `fmod`, `remainder`, `copysign`, `nextafter`, `fdim`, `fmax`, and `fmin`) by calling either an intrinsic or a C library function either of which expects `double` arguments. We previously converted the arguments to `_Common_float_type_t` which is `long double` when at least one argument is `long double`, resulting in narrowing conversion warnings at `/W4`. We now convert the arguments to `double` instead of `_Common_float_type_t`.

Fixes microsoft#3246
@CaseyCarter CaseyCarter added the bug Something isn't working label Dec 1, 2022
@CaseyCarter CaseyCarter requested a review from a team as a code owner December 1, 2022 18:21
stl/inc/cmath Show resolved Hide resolved
stl/inc/cmath Outdated Show resolved Hide resolved
Copy link
Contributor

@strega-nil-ms strega-nil-ms left a comment

Choose a reason for hiding this comment

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

Thank you!

Copy link
Member

@StephanTLavavej StephanTLavavej left a comment

Choose a reason for hiding this comment

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

Looks good - I checked <cmath> for other occurrences of casting arguments to common (case-insensitive) and found none.

@StephanTLavavej StephanTLavavej self-assigned this Dec 5, 2022
@StephanTLavavej
Copy link
Member

I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed.

@StephanTLavavej StephanTLavavej merged commit 2b3a09f into microsoft:main Dec 6, 2022
@StephanTLavavej
Copy link
Member

Thanks for investigating and fixing this warning! 🔍 ⚠️ 🛠️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

<cmath>: A compile-time warning C4244: 'argument': conversion from '_Common' to 'double'
6 participants