Vectorized minmax family functions return wrong index / value when input contains NaNs.
Generally when input contains NaN, the behavior is undefined, because f strict weak ordering violation.
However, if the input contains only NaN value elements or NaN value elements and only one non-NaN value elements, the behavior appears to be defined: the comparisons is all false, so the strict weak ordering is met.
We talked about this at the weekly maintainer meeting and decided that the cases of all-nans or all-nans-except-one-plain-value aren't worth worrying about, and the Standard is vague on whether they're UB.
Describe the bug
Vectorized minmax family functions return wrong index / value when input contains NaNs.
Generally when input contains NaN, the behavior is undefined, because f strict weak ordering violation.
However, if the input contains only NaN value elements or NaN value elements and only one non-NaN value elements, the behavior appears to be defined: the comparisons is all false, so the strict weak ordering is met.
The below modification of test case fails though.
Command-line test case
Expected behavior
The above test pass. The algorithm returns the result as per standard.
UB cases still may fail, any expectation are only about apparently valid cases.
STL version
https://github.com/microsoft/STL/commit/18c09c48f5666e6b1ea2a3724c5f6f9917c4c6fb
Additional context
Originally reported in https://github.com/microsoft/STL/pull/3928#issuecomment-2174232902