Skip to content

fix(build): drop -ffast-math so NaN convergence guards hold on macOS (4.5.1) - #39

Merged
gdifiore merged 1 commit into
mainfrom
fix/macos-ffast-math-hang-guard
May 26, 2026
Merged

gdifiore merged 1 commit into
mainfrom
fix/macos-ffast-math-hang-guard

Conversation

@gdifiore

Copy link
Copy Markdown
Owner

Problem

macOS CI failed on 4.5 Release:

72 - FlightSimulatorTest.NanModelThrowsInsteadOfHanging (Failed)
73 - FlightSimulatorTest.TrajectoryVariantAlsoGuardsAgainstHang (Failed)

Cause

Release built with -ffast-math (CMakeLists.txt:69), which implies -ffinite-math-only. That lets the compiler assume NaN/Inf never occur and fold NaN comparisons to a constant.

The convergence guards from bd56488 depend on IEEE semantics: NanAerodynamicModel poisons the trajectory with NaN, so AerialPhase::isPhaseComplete does NaN <= terrainHeight → false → phase never completes → step cap fires → runtime_error. Apple Clang folded that compare the other way, so the phase "completed" early, no throw, EXPECT_THROW failed. Linux kept it false, so CI stayed green.

The same flag makes std::isnan/isfinite unreliable, so an explicit finite-check guard wouldn't be robust under it either. The design (safety guards that detect divergence via NaN) is incompatible with -ffinite-math-only.

Fix

Drop -ffast-math, keep -O3. Bump to 4.5.1.

-ffast-math implies -ffinite-math-only, letting the compiler assume
NaN/Inf never occur and fold NaN comparisons to a constant. The run-loop
convergence guards rely on IEEE semantics: NaN <= terrainHeight must stay
false so a poisoned trajectory never falsely completes and the step cap
fires. Apple Clang folded the compare the other way, so
NanModelThrowsInsteadOfHanging and TrajectoryVariantAlsoGuardsAgainstHang
failed on macOS Release builds. Keep -O3.

Bump version to 4.5.1.
@gdifiore
gdifiore merged commit 45ecdf4 into main May 26, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant