Skip to content

Incorrect overflow in std::hypot #92782

@efriedma-quic

Description

@efriedma-quic

Consider:

#include <cmath>
float f = std::hypot(1e20f,1e20f,1e20f);

With libc++, this produces +inf. Other libraries appear to handle this correctly. (The C standard suggests hypot() should return a result "without undue overflow or underflow"... although that only applies to the two-argument form).

Metadata

Metadata

Assignees

No one assigned

    Labels

    libc++libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions