https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101794
Bug ID: 101794 Summary: std::lerp with NaN input does not result in NaN Product: gcc Version: 11.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: jonas.rahlf.basf at gmail dot com Target Milestone: --- >From the description of std::lerp I would have expected that providing NaN as t would result in NaN, but it does not. The return value should be "a+t(b−a)" so if t==NaN then the result should also be NaN. Example: #include <limits> #include <cmath> #include <iostream> int main() { constexpr float nan = std::numeric_limits<float>::quiet_NaN(); float result = std::lerp(1, 2, nan); std::cout << result << std::endl; // outputs 2 } Yields 2, see https://godbolt.org/z/do4zEhs5o . Compile with g++ -std=c++20. With clang you also get 2, but with MSVC you get NaN.