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

<random>: std::piecewise_constant_distribution<float>::densities() gives warning C4244 #3105

Closed
danielkrupinski opened this issue Sep 15, 2022 · 1 comment · Fixed by #3107
Labels
bug Something isn't working fixed Something works now, yay!

Comments

@danielkrupinski
Copy link

#include <iostream>
#include <random>

int main()
{
    std::piecewise_constant_distribution<float> dist;

    for (auto density : dist.densities())
        std::cout << density << '\n';
}

https://godbolt.org/z/63Pj7d3qE

@CaseyCarter CaseyCarter added the bug Something isn't working label Sep 15, 2022
CaseyCarter added a commit to CaseyCarter/STL that referenced this issue Sep 15, 2022
…ties

This function converts a `vector` of `double` to a `vector` of `_Ty`, which is a narrowing conversion when `Ty` is `float`. It's silly to warn about this when the Standard makes it clear that the narrowing will occur, and the user has asked for such explicitly by calling `piecewise_constant_distrubution<float>::densities`.

Fixes microsoft#3105.
CaseyCarter added a commit to CaseyCarter/STL that referenced this issue Sep 15, 2022
…ties

This function converts a `vector` of `double` to a `vector` of `_Ty`, which is a narrowing conversion when `Ty` is `float`. It's silly to warn about this when the Standard makes it clear that the narrowing will occur, and the user has asked for such explicitly by calling `piecewise_constant_distrubution<float>::densities`.

Fixes microsoft#3105.
@CaseyCarter
Copy link
Contributor

Thanks for the report! This narrowing is definitely our problem and not the users, we shouldn't emit a warning.

@StephanTLavavej StephanTLavavej added the fixed Something works now, yay! label Sep 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed Something works now, yay!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants