-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
VS 2022 17.4 reproduces different result with std::ranges compared to older version #3199
Comments
It looks like a STL bug. Thanks for reporting! |
This is not a bug. Short explanation: What was happening before VS 17.4Iterators of your
Vector constructor in 17.3: Lines 693 to 715 in 60decd0
What is going on in VS 17.4#1794 changed Output of the program from your "Compiler Explorer" example:
General problemThe general problem is that this program has undefined behaviour - the predicate of your filter does not model |
Thanks @JMazurkiewicz - we talked about this at the weekly maintainer meeting and your analysis is perfect. 😻 The behavior is indeed undefined because the predicate returns different answers when repeatedly invoked. Closing this issue as by design - thanks for the report. |
Thank you for your extensive answer! |
Copying a view with filter and transform in VS 2022 17.4 (exact compiler version is MSVC 19.34.31933.0) to a vector behaves differently compared to older versions.
Below is a small code snippet is shown. The code should filter unique integer values and transform them to a string, and should be copied to a new vector.
Godbolt link: https://godbolt.org/z/d7TTfq9K5
The expected result is that
std::vector<std::string> js
is size 2 and only includes"1"
and"2"
, but with the newer VS compiler the vector is size 1 and contains only"1"
,I'm not 100% sure whether this code sample has always been wrong, and the older compilers were printing the correct output by accident. Or a bug has been introduced with VS 2022 17.4..
The text was updated successfully, but these errors were encountered: