Skip to content

[WARING]: Compile Warning #5610

Open
Open

Description

@NNUCJ

Required prerequisites

What version (or hash if on master) of pybind11 are you using?

master

Problem description

We notice the compile warning in this file [include/pybind11/complex.h:58]

The warning is shown below:
warning: comparing floating point with == or != is unsafe [-Wfloat-equal]

Detail Code is shown below:
if (result.real == -1.0 && PyErr_Occurred())

I would like to konw your team will consider resolving this compilation alert ? In which version will the compilation alarm be removed ?

Reproducible example code


Is this a regression? Put the last known working version here if it is.

Not a regression

Activity

  1. added
    triage
    on Apr 10, 2025
  2. henryiii commented on Jun 3, 2025

    @henryiii
    Collaborator

    Getting rid of this is hard; this is literally how CPython communicates errors, we are not doing something wrong here. This is an extremely pedantic warning; I'd recommend not enabling it (or passing -Wno-float-equal) on code that uses CPython (including pybind11). It's really just trying to protect you from comparing computed values, something like .1 + .2 == .3.

    If someone wanted to put warning suppression pragmas around everything in pybind11, we probably could review such a patch, as long as it wasn't too long.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions