This bugzilla service is closed. All entries have been migrated to https://gitlab.com/libeigen/eigen
Bug 1393 - wrongly calling _init1<T>()
Summary: wrongly calling _init1<T>()
Status: RESOLVED FIXED
Alias: None
Product: Eigen
Classification: Unclassified
Component: Core - expression templates (show other bugs)
Version: 3.3 (current stable)
Hardware: All All
: Normal Compilation Problem
Assignee: Nobody
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 3.3
  Show dependency treegraph
 
Reported: 2017-02-16 22:07 UTC by cDc
Modified: 2019-12-04 16:49 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.
Comment 5 Nobody 2019-12-04 16:49:34 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to gitlab.com's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.com/libeigen/eigen/issues/1393.

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