Comparing floating-point with ‘==’ or ‘!=’ is unsafe · Issue #819 · ThrowTheSwitch/Unity · GitHub
Skip to content

Comparing floating-point with ‘==’ or ‘!=’ is unsafe #819

Description

@xqgex

When compiling the latest stable version (v2.6.1) using GCC 14 I am getting the following errors:

unity.c:356:16: error: comparing floating-point with ‘==’ or ‘!=’ is unsafe [-Werror=float-equal]
  356 |     if (number == 0.0f)
      |                ^~
unity.c:423:52: error: comparing floating-point with ‘==’ or ‘!=’ is unsafe [-Werror=float-equal]
  423 |         if ((n & 1) && (((UNITY_DOUBLE)n - number) == 0.5f))
      |                                                    ^~

In master latest commit 747c2ee those are at lines 370 and 437

Unity/src/unity.c

Lines 369 to 373 in 747c2ee

Unity/src/unity.c

Lines 435 to 439 in 747c2ee

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions