Skip to content

[BUG]: constexpr math functions fail to compile on domain/special inputs #135

Description

@Rinzii

Due Diligence

  • I have searched for similar issues before starting this bug report

Describe the bug

Several functions call the non-constexpr set_errno_if_required on their domain-error/special path without an is_constant_evaluated() guard, so evaluating them in a constant expression is ill-formed.

Guarding is inconsistent: sqrt(-1), fmod(1,0), and scalbn(inf,2) compile fine.

Steps to reproduce

#include <ccmath/ccmath.hpp>

// each of these fails to compile
constexpr double a = ccm::log(0.0);
constexpr double b = ccm::log(-1.0);
constexpr double c = ccm::acos(2.0);
constexpr double d = ccm::pow(-1.0, 0.5);
constexpr double e = ccm::tgamma(0.0);
constexpr int f = ccm::ilogb(0.0);

int main() {}

Error: non-constexpr function 'set_errno_if_required' cannot be used in a constant expression.

Expected behavior

All should compile as constant expressions and return the correct special value (for example log(0) = -inf), raising no errno at compile time.

Compiler version and type

Apple clang 17.0.0 (clang-1700.4.4.1)

Operating System

No response

Screenshots

Not applicable

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Bug: ReplicatedReproduced by at least one other person.

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions