[QUESTION] pybind11+eigen warning in O2 optimization with gcc
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 18k
- Forks
- 2.3k
- Avg merge
- 5d 17h
- Merged PRs (30d)
- 10
Description
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: f61855b9d8821e2576960109a2a67379a6c2366f
python-3.8
compiler: g++ (Debian 10.2.1-6) 10.2.1 20210110
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the report using test.cc, the shown g++ command, and the recorded Eigen, pybind11, Python, and GCC versions. Start by examining the compiler warning through the Eigen/Dense and pybind11/eigen.h includes; done would mean establishing whether the warning is caused by pybind11 and identifying a clear resolution or confirmed upstream cause.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100