Skip to content

UB when converting a float-point value to a type that can't represent its value #140980

Open
@shafik

Description

@shafik

clang used to flag this as undefined behavior:

#include <limits>

void foo() {
 constexpr double d2 = std::numeric_limits<double>::max();         
 constexpr float f = d2;
}

back in clang-8 but it has not since: https://godbolt.org/z/5K1da874d

Based on conv.double p1 I think this is still UB.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"floating-pointFloating-point math

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions