New user self-registration is currently disabled. Please email eigen-core-team @ lists.tuxfamily.org if you need an account.
Bug 1393 - wrongly calling _init1<T>()
wrongly calling _init1<T>()
Status: RESOLVED FIXED
Product: Eigen
Classification: Unclassified
Component: Core - expression templates
3.3 (current stable)
All All
: Normal Compilation Problem
Assigned To: Nobody
:
Depends on:
Blocks: 3.3
  Show dependency treegraph
 
Reported: 2017-02-16 22:07 UTC by cDc
Modified: 2017-02-20 09:16 UTC (History)
3 users (show)



Attachments
code to reproduce the error (462 bytes, text/plain)
2017-02-16 22:07 UTC, cDc
no flags Details

Description cDc 2017-02-16 22:07:38 UTC
Created attachment 776 [details]
code to reproduce the error

Not able to use a custom structure, that exposes an operator to access it as an Eigen matrix, as a Eigen type. Please see the simple example attached.

The compilation failes with VC2015 with the following message:

```
1>d:\pro\lib\eigen\eigen\src\core\matrix.h(296): error C2664: 'void Eigen::PlainObjectBase<Eigen::Matrix<double,3,1,0,3,1>>::_init1<T>(const double *)': cannot convert argument 1 from 'const TPoint3<TYPE>' to 'Eigen::EigenBase<Derived>::Index'
1>          with
1>          [
1>              T=TPoint3<TYPE>
1>          ]
1>          and
1>          [
1>              Derived=Eigen::Matrix<double,3,1,0,3,1>
1>          ]
1>  d:\pro\lib\eigen\eigen\src\core\matrix.h(296): note: No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
1>  d:\pro\src\consoleapplication1\consoleapplication1.cpp(22): note: see reference to function template instantiation 'Eigen::Matrix<double,3,1,0,3,1>::Matrix<TPoint3<TYPE>>(const T &)' being compiled
1>          with
1>          [
1>              T=TPoint3<TYPE>
1>          ]
1>  d:\pro\src\consoleapplication1\consoleapplication1.cpp(22): note: see reference to function template instantiation 'Eigen::Matrix<double,3,1,0,3,1>::Matrix<TPoint3<TYPE>>(const T &)' being compiled
1>          with
1>          [
1>              T=TPoint3<TYPE>
1>          ]
```
Comment 1 Gael Guennebaud 2017-02-17 13:12:36 UTC
You can workaround with 

Eigen::Matrix<TYPE,3,1> eX = X;

and the fix for the devel branch is there:

https://bitbucket.org/eigen/eigen/commits/e6ef61a3bd12/
Summary:     Bug 1393: enable Matrix/Array explicit ctor from types with conversion operators (was ok with 3.2)

I'll wait a bit before backporting.
Comment 2 cDc 2017-02-17 19:05:27 UTC
Thank you for the fast fix! I can confirm that this error is solved now (at least in my library). I see it is quite e big fix, so I understand your precaution.

Now however I get a ton of warnings as no param is used for the macro you just added:
```
warning C4003: not enough actual parameters for macro 'EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN'
```

Could you please use __VA_ARGS__ instead of X in order to fix this warning?

I get other errors now from upgrading from 3.2.11 to 3.3 (default), but I guess I should open a different bug report.

Thanks!
Comment 3 Gael Guennebaud 2017-02-20 09:15:16 UTC
Backported: https://bitbucket.org/eigen/eigen/commits/372711b73f7b/
Comment 4 Gael Guennebaud 2017-02-20 09:16:14 UTC
Regarding the warnings, I prefer tot to rely on variadic macros. BLA_BLA({}) does the job.

Note You need to log in before you can comment on or make changes to this bug.