Package: libstdc++6
Version: 13.2.0-9

Streaming a negative NaN float produces "-nan" with g++ -O0 and "nan"
with g++ -O1 or above:

        $ cat >mwe.cc <<EOF
        > // Copyright 2023 Google LLC
        > // SPDX-License-Identifier: Apache-2.0
        > 
        > #include <bit>
        > #include <iostream>
        > 
        > int main() { std::cerr << std::bit_cast<float>(0xfff80000) << '\n'; }
        > EOF
        $ g++ -std=c++20 -O0 mwe.cc && ./a.out
        nan
        $ g++ -std=c++20 -O1 mwe.cc && ./a.out
        -nan
        $ clang++ -std=c++20 -O0 mwe.cc && ./a.out
        nan
        $ clang++ -std=c++20 -O1 mwe.cc && ./a.out
        -nan

For comparison, on amd64, this program always produces "-nan",
regardless of optimization level.

Tested with g++-13 13.2.0-9 and clang-16 1:16.0.6-19.

Reply via email to