A robot command path may contain an apparently explicit check for NaN or infinity and still behave differently after release optimisation. Before blaming the sensor or rewriting the check, inspect the floating-point assumptions under which that check was compiled.

Optimisation flags are part of the command-validation design. A numerical kernel that assumes all inputs are finite and a boundary whose job is to detect non-finite inputs do not necessarily have compatible compilation requirements.

### The source code is not the complete contract

The official [GCC optimisation documentation](https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html) states that `-ffinite-math-only` permits optimisations assuming arguments and results are not NaNs or infinities. It also documents that `-ffast-math` enables this option among other changes.

Under such assumptions, code whose purpose depends on observing a non-finite value can be simplified in ways that defeat the programmer's intended diagnostic. That does not mean every compiler, flag combination or guard implementation produces the same machine code. It means a source-level `isfinite` call is not sufficient evidence that the deployed boundary retains the intended behaviour.

A common integration risk is applying one performance-oriented flag set to an entire target, including validation wrappers, generated inference code and controller interfaces. An inline helper may inherit the caller's assumptions; link-time optimisation deserves review too.

### Range checks do not necessarily catch the same fault

A check written as “below the lower limit or above the upper limit” can also fail to reject a NaN under ordinary floating-point comparison semantics, because those ordered comparisons are false for NaN. A large finite value, an infinity and a NaN are therefore separate test cases.

Replacing an invalid command with zero is not automatically a suitable recovery either. Zero may be a physical target rather than a neutral action. The response must follow the controller's validated fault behaviour, including what happens to queued references and which component owns any transition.

This application check is not a replacement for independent protective functions.

### Test the release boundary with actuation disconnected

A useful evidence package would include:

- Compiler version, target architecture and the effective options for the validation code.
- The actual release artifact, including link-time optimisation settings.
- Runtime-supplied finite values, boundary values, infinities and quiet NaNs.
- The validation decision and whether the downstream command interface was invoked.
- Machine-code or compiler-output inspection where the expected decision disappears.

Keep the test input from being a compile-time constant if the purpose is to examine runtime classification. A debug-only unit test or a test compiled with different options does not establish the behaviour of the shipping artifact.

Signalling NaNs, floating-point exception modes and accelerator-to-CPU conversions introduce additional platform-specific questions; they should not be assumed to match a desktop test.

### Separate performance assumptions from validation requirements

One design is to give boundary-validation code explicitly reviewed compilation settings and a narrow interface to accelerated numerical code. That separation still requires verification: inlining, whole-program optimisation and build-system propagation can blur it. Merely moving a function into another source file is not proof of isolation.

The tradeoff is maintenance and integration complexity, not a blanket argument against optimisation. Document which components may assume finite inputs and which must establish that precondition.

**Open engineering question:** does your release qualification inject non-finite values at the real command-validation boundary, and can the build record show that the compiler's assumptions agree with the fault the guard is supposed to detect?