Re: [eigen] Possible Bug ?

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]



I came up with an extreme simple failure case which does not make use of Eigen. I'll report it to GCC's team:


----- func.h -----

#ifndef FUNC_H
#define FUNC_H

namespace Bar {
  enum { RowMajor };
  
  template<int Size, int Options =  ((Size==1) ? RowMajor : 0)>
  class Matrix { };
}

template <int N> void foo(Bar::Matrix<N> &m);

template <> void foo<2>(Bar::Matrix<2> &m);

#endif


---- func.cpp -----
#include "func.h"
template <> void foo<2>(Bar::Matrix<2> &m) {}


---- main.cpp -----

// the namespace is optional
namespace riri { enum { fifi = sizeof(int) }; }

#include "func.h"

int main() {
  Bar::Matrix<2> B;
  foo<2>(B);
}


$ g++ func.cpp main.cpp

cheers,
Gael


On Tue, Jul 15, 2014 at 1:23 PM, Matthieu Brucher <matthieu.brucher@xxxxxxxxx> wrote:
Hi,

Did you try by changing the order of vector/Eigen headers?

2014-07-15 12:20 GMT+01:00 Helmut Jarausch <jarausch@xxxxxxxxxxxxxxxxxxx>:
> On 07/15/2014 01:02:29 PM, Gael Guennebaud wrote:
>>
>> I found the one line triggering the issue. Using the stackoverflow
>> example,the following main.cpp file is sufficient to trigger the issue:
>>
>>
>> namespace riri { // the namespace is optional
>>   enum { fifi = sizeof(int) };
>> }
>>
>> #include "func.h"
>>
>> int main() {
>>     std::vector<Eigen::Matrix<double, 2, 2> > m;
>>     f<2>(m);
>> }
>>
>>
>> that is, adding the declaration:
>>
>> enum { fifi = sizeof(int) };
>>
>> *before* including Eigen makes gcc's linker nuts.
>>
>> I'm clueless.
>>
>> gael
>>
>
> Probably, I haven't understood the issue.
>
> The following cases compile and link fine with gcc-4.9.0
>
> Case I)  gcc Bug1.C
>
> Bug1.C :
>
> #include <Eigen/Dense>
> #include <vector>
>
> template <int N>
> void f(std::vector<Eigen::Matrix<double, N, N> >& m);
>
>
> template <>
> void f<2>(std::vector<Eigen::Matrix<double, 2, 2> >& m) {}
>
> enum { fifi = sizeof(int) };
>
>
> int main() {
>     std::vector<Eigen::Matrix<double, 2, 2> > m;
>     f<2>(m);
> }
>
>
> Case II)  gcc Bug2.C func.C  where
>
> Bug2.C :
> #include <Eigen/Dense>
> #include <vector>
>
> template <int N>
> void f(std::vector<Eigen::Matrix<double, N, N> >& m);
>
> enum { fifi = sizeof(int) };
>
>
> int main() {
>     std::vector<Eigen::Matrix<double, 2, 2> > m;
>     f<2>(m);
> }
>
> func.C :
> #include <Eigen/Dense>
> #include <vector>
> template <int N>
> void f(std::vector<Eigen::Matrix<double, N, N> >& m);
>
> template <>
> void f<2>(std::vector<Eigen::Matrix<double, 2, 2> >& m) {}
>
>
> Helmut
>
>
>



--
Information System Engineer, Ph.D.
Blog: http://matt.eifelle.com
LinkedIn: http://www.linkedin.com/in/matthieubrucher
Music band: http://liliejay.com/





Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/