Menu

#910 isnan(NAN) results in -1 instead of +1 in C99 mode

v1.0 (example)
closed-invalid
nobody
None
5
2021-07-29
2021-07-29
No

In GCC, CLANG, MSVC and ICC, calling the C99 macro isnan on a double NAN will evaluate to 1, while in mingw it evaluates to -1 instead. Strictly speaking, I guess it's still standard-compliant, but a source of bugs and differences w.r.t pretty much every other compiler. Would be nice if it could evaluate instead to 1.

Discussion

  • Doug Semler

    Doug Semler - 2021-07-29

    It's not "strictly speaking." It's "standards compliant." First rule of compilers, never take results that are standard compliant and compare values. The comparison code is broken if it expects +1, as any nonzero value is valid.

     
  • Doug Semler

    Doug Semler - 2021-07-29
    • status: open --> closed-invalid
     

Log in to post a comment.