Re: [eigen] Lazy evaluation bug, feature, or PEBKAC? |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] Lazy evaluation bug, feature, or PEBKAC?
- From: Benoit Jacob <jacob.benoit.1@xxxxxxxxx>
- Date: Tue, 1 Mar 2011 16:07:40 -0500
- Cc: Dave Steffen <dave.steffen@xxxxxxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=wDhJ14/Xkl3SP9pqj96SqmTQmznZszoFFzWnETqWwXI=; b=qsGPxiLaSrF8KdW/QbQG0HPoFgOQrap0Q6Sh3RbaYuTe5XAP6SZjE9Sh5XtOHT2zfm 66aBohYrw8Ak+zRNIHq9KlPn26gfFY+R0G5Niw2fEg4HVo9Niy122JUnPpjC/C0ukmV+ r3tr/0kFpDw1hMaI/JboSmilAY0zsE4/JIXp4=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=f3jjOVqRklyYijXDkGstQurnAacL2Y738T1diCa9J19rpXKYroe6tAIU1TnE3lThoI 55S4uZQAod7IYPVumt4t3z8MdtFjlq7v54vC966IbtKWfMIhLbW16HaN/8/hX/KtqHnj BXESnzZwCUvfJJ/Tno2Cj2sIuU6eAN3rsE1Gk=
Hi,
I can reproduce the crash with Eigen2. It's a plain Eigen2 bug which
I'm surprised we didn't catch before.
This is not affecting Eigen3. You program compiles unmodified against
Eigen3 with -DEIGEN2_SUPPORT and there it works fine.
Benoit
2011/3/1 Dave Steffen <dave.steffen@xxxxxxxxxxx>:
> Hi Folks
>
> We're just getting into Eigen (very impressive library), and I
> encountered the following suprising (to me) behavior:
>
> #include <Eigen/Dense>
>
> using std::cout;
> using std::endl;
>
> // import most common Eigen types
> USING_PART_OF_NAMESPACE_EIGEN
>
> int main()
> {
> Vector3d a, b;
>
> a << 1, 2, 3;
> b << 7, 8, 9;
>
> auto x = (a+b).col(0); // line 1
>
> cout << x[0] << endl;
> cout << x[1] << endl;
> }
>
> ... produces a core dump, or worse behavior.
>
> Replacing line 1 with:
>
> auto x = (a+b).eval().col(0);
>
> fixes the problem.
>
> This looks like a lazy-evaluation bug, in that operator[] probably
> ought to evaluate the expression. OTOH I've been wrong before. :-)
>
> This is using Eigen 2.0.15 with GCC 4.5.1.
>
> Any insights appreciated. Thanks very much!
>
>
> --
> Dave Steffen, Ph.D. - Software Engineer
>
> Numerica Corporation <http://www.numerica.us>
> 4850 Hahns Peak Drive, Suite 200
> Loveland, Colorado 80538
> main (970) 461-2000 x 227 direct (970) 612-2327
> Email: dave.steffen@xxxxxxxxxxx
>
>
>
>