Skip to content

[clang] gcc compatibility regarding constexpr evaluation of __builtin_* for math functions #62049

@chris-durand

Description

@chris-durand

GCC allows to evaluate all math built-ins in a constexpr context. libstdc++ even provides extended constexpr math functions, like constexpr std::sin. That library extension is in violation of the C++ standard but libstdc++ developers decided to keep it nevertheless.

The feature is especially useful in embedded code bases for small devices to do complex pre-computations at compile-time.

Could it be acceptable to make most math built-ins available from a constexpr context in Clang? The change should not cause any non-conformities since functions in libc++ are still not constexpr. Users who heavily rely on the constexpr behaviour could define their own functions using the built-ins and more easily migrate from GCC to Clang.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"constevalC++20 constevalenhancementImproving things as opposed to bug fixing, e.g. new or missing feature

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions