Support C++11 initializer lists

Submitted by Ilja Honkonen

Assigned to Nobody

Link to original bugzilla bug (#954)
Version: 3.3 (current stable)

Description

Created attachment 544
program

The attached program assert even though I only use Eigen::Vector3d:

Assertion failed: (((SizeAtCompileTime == Dynamic && (MaxSizeAtCompileTime==Dynamic || size<=MaxSizeAtCompileTime)) || SizeAtCompileTime == size) && size>=0), function resize, file /Users/iljah/libraries/eigen/Eigen/src/Core/PlainObjectBase.h, line 282.

Program received signal SIGABRT, Aborted.  
0x00007fff8f531866 in __pthread_kill ()  
(gdb) up  
#1  0x00007fff8c30635c in pthread_kill ()  
(gdb)   
#2  0x00007fff8a6adb1a in abort ()  
(gdb)   
#3  0x00007fff8a6779bf in __assert_rtn ()  
(gdb)   
#4  0x0000000100000c87 in Eigen::PlainObjectBase<Eigen::Matrix<double, 3, 1, 0, 3, 1> >::resize (this=0x7fff5fbffa98, size=0) at PlainObjectBase.h:282  
282	      eigen_assert(((SizeAtCompileTime == Dynamic && (MaxSizeAtCompileTime==Dynamic || size<=MaxSizeAtCompileTime)) || SizeAtCompileTime == size) && size>=0);  
(gdb)   
#5  0x0000000100000c05 in Eigen::PlainObjectBase<Eigen::Matrix<double, 3, 1, 0, 3, 1> >::_init1<int> (this=0x7fff5fbffa98, size=0) at PlainObjectBase.h:713  
713	      resize(size);  
(gdb)   
#6  0x0000000100000b9a in Eigen::Matrix<double, 3, 1, 0, 3, 1>::Matrix<int> (this=0x7fff5fbffa98, x=@0x7fff5fbffa74) at Matrix.h:244  
244	      Base::template _init1<T>(x);  
(gdb)   
#7  0x0000000100000b3d in Eigen::Matrix<double, 3, 1, 0, 3, 1>::Matrix<int> (this=0x7fff5fbffa98, x=@0x7fff5fbffa74) at Matrix.h:245  
245	    }  
(gdb)   
#8  0x0000000100000b16 in f<Eigen::Matrix<double, 3, 1, 0, 3, 1> > (data=@0x7fff5fbffac8) at test.cpp:7  
7		return T{0};  
(gdb)   
#9  0x0000000100000a9c in main () at test.cpp:14  
14		const Eigen::Vector3d v = f(data);  
  

Looks like the assert goes away if I use return T{0, 0, 0}; instead of return T{0}; This looks like a bug in initialization logic of Vector3d since that's what T is deduced to. I can't use {0, 0, 0} if T is double so supporting also scalar init of matrices would be nice. And looks like old style initialization with T(0) gives the same result.

Attachment 544, "program":
test.cpp

Edited Feb 03, 2021 by David Tellenbach
Assignee Loading
Time tracking Loading