# A piece of code that causes LLVM Flang to generate NaN/Inf randomly

**URL:** <https://fortran-lang.discourse.group/t/a-piece-of-code-that-causes-llvm-flang-to-generate-nan-inf-randomly/10713>\
**Category:** Flang\
**Created:** [February 11, 2026, 5:39pm UTC](https://fortran-lang.discourse.group/t/a-piece-of-code-that-causes-llvm-flang-to-generate-nan-inf-randomly/10713 "2026-02-11T17:39:52Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![certik](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/certik/32/4_2.png) [@certik](https://fortran-lang.discourse.group/u/certik)\
**Post date:** [February 14, 2026, 3:03pm UTC](https://fortran-lang.discourse.group/t/a-piece-of-code-that-causes-llvm-flang-to-generate-nan-inf-randomly/10713/8 "2026-02-14T15:03:37Z")

</div>

> [@JohnCampbell](#):
>
> If the modelling approach is improved, then the errors due to -ffast-math are never significant.  
> I have only observed problems using -ffast-math when the floating point values are so unusual, due to the poor modelling approach.

Yes, I’ve been using `-ffast-math` with great success also, and never had any issues. I started this thread here about it: [Can one design coding rules to follow so that `-ffast-math` is safe?](https://fortran-lang.discourse.group/t/can-one-design-coding-rules-to-follow-so-that-ffast-math-is-safe/2762), and I link a document there about some rules to follow that make using `-ffast-math` “safe”.

---

_[View the full topic](https://fortran-lang.discourse.group/t/a-piece-of-code-that-causes-llvm-flang-to-generate-nan-inf-randomly/10713)._
