Skip to content

[QUESTION] pybind11+eigen warning in O2 optimization with gcc #3014

Open
@anciaux

Description

@anciaux

Thanks for maintaining this project. I love it.

When I compile the ode below, mainly involved with the use of Eigen+Pybind11 I have unexpected compilation warnings appearing:

#include <Eigen/Dense>
#include <pybind11/eigen.h>
#include <pybind11/pybind11.h>

namespace py = pybind11;

void foo() {
  py::object val;
  pybind11::cast<Eigen::Vector3d>(val);
}

I compile it with:
g++ -Wall -c -O2 -I $EIGEN_INCLUDE_PATH -I $PYBIND11_INCLUDE_PATH -I $PYTHON_INCLUDE_PATH test.cc
to obtain:

Eigen/src/Core/DenseStorage.h:211:9: warning: ‘<anonymous>’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  211 |         m_data = std::move(other.m_data);

This suggest a temporary object is partially initiallized during the cast (or confuses the compiler)
I am trying to remove such worrying warnings for sanity. Any help is really appreciated.

Information of the system setup:

eigen: 391094c50743f28f9174f455661f650bf07e0177
pybind11: f61855b
python-3.8
compiler: g++ (Debian 10.2.1-6) 10.2.1 20210110

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions