84. Negative sqrt traps in cpl run and cpl build --checked (2026-11-21)
sqrt(x)forx < 0.0traps withsqrt(<x>) of a negative number(exit 3) incpl-interpand under-DLOCAL(cpl build --checked), while release builds stay rawstd::sqrt(x).- Reason: Calling
sqrton a tiny negative float (e.g.r*r - d*d = -1e-15from rounding) previously produced a silentNaNthat poisoned downstream comparisons and sorts (flt_sqrt_neg_nan, the last unhandled case in the P0floating-pointbug-replay class). Checkingx < 0.0incpl-interpand inside#ifdef LOCALincpl::fsqrtcatches the domain error identically in debug and checked builds with zero release overhead (-0.0 < 0.0is false, sosqrt(-0.0)still succeeds). Bringsfloating-pointbug-replay to 6/6 (100%) and total P0 bug-replay to 60/63 (95.2%). - Test:
sqrt_negative_traps_in_interp_and_checked_cpp_not_release,golden_math_assert_and_input_errors, andbench/goal_tests/bug_replay/flt_sqrt_neg_nan.cp. - Reverse: Remove the
x < 0.0check incrates/cpl-interp/src/lib.rs, remove thefsqrtpiece fromcrates/cpl-codegen/src/runtime.rs, and emitstd::sqrt(...)directly incrates/cpl-codegen/src/expr.rs.
- Reason: Calling