Closed mnobrecastro closed 3 years ago
Thank you for this fantastic and very informative bug report! It seems to me like putting aligned_free
(and aligned_malloc
) in the pcl namespace would be the best solution. It would be great if you could try that out and see if it fixes the problem for you.
aligned_{malloc,free}
are used in PCL for just recognition (linemod). With some refactoring, we might be able to eliminate that. For now, a temporary fix would be to move the free functions to pcl namespace.
I believe, this is an oversight (of keeping the functions outside the namespace, perhaps since the header is for macros only) on our part.
Thank you for the quick help and for the kind words. The namespace pcl
fix on the PCL
side works indeed for both aligned_{malloc,free}
:
pcl/common/include/pcl/pcl_macros.h (lines 379-415)
namespace pcl {
inline void*
aligned_malloc(std::size_t size) {...}
inline void
aligned_free(void* ptr) {...}
} // namespace pcl
As a quick note, before applying the pcl fix, I managed somehow to trigger another aligned_free
overloading error while using the GeneralizedEigenSolver
in my main project. This time in a different line from that I had temporarily fixed on the Eigen
side.
After looking at the Eigen\src\Core\util\Memory.h script, I noticed that sometimes they prefix the aligned_{malloc,free}
calls with their "Eigen::internal::"
namespace, but sometimes they don't. More problems may arise with other libs depending on Eigen
.
Thank you for your time, once more!
@mnobrecastro would you be interested in getting the PR started?
Dear @mvieth and @kunaltyagi, I have done the PR as agreed. Thank you guys!
Describe the bug
Good evening everyone! I am not sure this "ambiguous call" issue has been raised before, but while I was attempting to use the
GeneralizedEigenSolver(const MatrixType&, const MatrixType&, bool)
from theEigen
lib (which belongs to the<Eigen/Eigenvalues>
module), I came across this overloading conflict of the function'void aligned_free(void *)'
which seems to be declared in bothPCL
andEigen
.pcl/common/include/pcl/pcl_macros.h (lines 401-415)
Eigen\src\Core\util\Memory.h (lines 173-181/328-335)
Context
Due to the nature of the problem I am working on, I expect to use some depth data to solve a generalized eigenvalue problem of the type Av=λBv, where A and B are two matrices and where the λ and v correspond, respectively to the generalized eigenvalues and eigenvectors of that matrix pair. Given the singular nature of the B matrix that I must use, other alternatives such as the
GeneralizedSelfAdjointEigenSolver
cannot help me reach the solution. It must be done by theGeneralizedEigenSolver
. Furthermore, I have never previously had any issues with the#include <Eigen/Eigenvalues>
module before, so this bug is directly triggered by dependency concerning theGeneralizedEigenSolver
which has to do with the use/conversion of the std::complex numbers in its source, even though the method only works with fully Real matrices A and B.Expected behavior
Being able to reproduce the example shown in the
GeneralizedEigenSolver
's page:Please note that the results below may change given that the matrices A and B are randomly generated:
Current Behavior
The solution does not build due to the above mention overloading of the two
'void aligned_free(void *)'
functions:To Reproduce
CMakeLists.txt
pcl-ges.cpp
Environment:
Possible Solution
I adopted this temporary fix on the
Eigen
side by prepending the namespace"Eigen::internal::"
to thealigned_free(ptr)
on line 334 as suggested by the compiler, but it perhaps would be more practical to have a similar namespace solution for the aligned_free(ptr) on thePCL
side. I leave this temp suggestion, but please let me know whether is there another fix just on thePCL
side. Thank you very much for your time!Eigen\src\Core\util\Memory.h (lines 328-335)