Skip to content

Conversation

@iv-m
Copy link

@iv-m iv-m commented Jan 21, 2026

With -ffinite-math-only (implied by -ffast-math and -Ofast), GCC considers all comparisons against infinities to be false and can optimize them away. This breaks several tests that rely on infinities to be compared correctly. To avoid this, we add GCC-specific optimize attribute that disables -ffinite-math-only optimization for floating point comarisions used in assertions.

With `-ffinite-math-only` (implied by `-ffast-math` and -Ofast),
GCC considers all comparisons against infinities to be false
and can optimize them away. This breaks several tests that rely
on infinities to be compared correctly. To avoid this, we add
GCC-specific optimize attribute that disables `-ffinite-math-only`
optimization for floating point comarisions used in assertions.

Signed-off-by: Ivan A. Melnikov <iv@altlinux.org>
mr-c added 2 commits January 22, 2026 15:15
From the GCC manual page:

> Disregard strict standards compliance. -Ofast enables all -O3 optimizations.
> It also enables optimizations that are not valid for all standard-compliant
> programs. It turns on -ffast-math, -fallow-store-data-races.
> It turns off -fsemantic-interposition.

On recent clang, use "-O3 -ffast-math" due to
> error: argument '-Ofast' is deprecated; use '-O3 -ffast-math' for the same
> behavior, or '-O3' to enable only conforming optimizations
> [-Werror,-Wdeprecated-ofast]
@mr-c mr-c force-pushed the tests-no-finite-math-only branch from 30e03ea to cea5dd8 Compare January 22, 2026 14:46
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.

2 participants