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

  1. added
    Bug: ReplicatedReproduced by at least one other person.
    and removed on Jun 13, 2026
  2. added this to the Road to v1.0.0 milestone on Jun 16, 2026
  3. self-assigned this
    on Jun 17, 2026
  4. linked a pull request that will close this issueCCMath 0.3.0 Release Candidate #149on Jun 19, 2026
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