Skip to content

Cfenv.HoldAndUpdateEnv fails in the Clang 22 hardened build: division moved past fetestexcept #379

Closed

Description

@homer6

Found by the v0.5.0 fix-up run (https://github.com/homer6/cpp-docs/actions/runs/41689101415), tracking #363. The job never ran in the first release run (apt.llvm.org outage).

linux.yml / Clang 22 libcxx hardened: 1543/1544 pass, Cfenv.HoldAndUpdateEnv fails:

cfenv_test.cpp:169: Expected equality: r Which is: inf, 0.0
cfenv_test.cpp:170: Expected: false (fetestexcept(FE_DIVBYZERO))

The hardened build is -O2. The test's quiet_reciprocal has no #pragma STDC FENV_ACCESS ON, so Clang may move 1.0 / x past fetestexcept. The page's own example has the pragma, and so do the other tests that need it (block scope, Clang only). Fix: the same pragma in the test's quiet_reciprocal, matching the page.

Activity

  1. self-assigned this
    on Nov 3, 2026
  2. homer6 commented on Nov 3, 2026

    @homer6
    OwnerAuthor

    Delivered in #382.

    What changed

    • The test's quiet_reciprocal has #pragma STDC FENV_ACCESS ON (block scope, Clang only), like the page's example.

    Why

    • Reproduced on Ubuntu 26.04 amd64 with Clang 22 + libc++, hardened, RelWithDebInfo: fails before, Cfenv 9/9 after.

    Still open

    • Proof in CI: the Clang 22 hardened job re-run.
  3. homer6 commented on Nov 3, 2026

    @homer6
    OwnerAuthor

    Merged in #382 (ea45912).

    What changed

    • Nothing since the PR was opened: no follow-up commits and no rebase.

    Why

    • Merged on the owner's review.

    Still open

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions