Re: [eigen] Clang issue on MacOS when the set variable is used in the given data |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen <eigen@xxxxxxxxxxxxxxxxxxx>
- Subject: Re: [eigen] Clang issue on MacOS when the set variable is used in the given data
- From: Gael Guennebaud <gael.guennebaud@xxxxxxxxx>
- Date: Fri, 19 Apr 2013 12:05:56 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:in-reply-to:references:from:date:message-id :subject:to:content-type; bh=jTBIwuqRNUxZqk8PJRrK6hcUJcAwJ6XJOI6/6XFExvY=; b=RvYmJpUM212bzDG+shheo3nZZiBAOZY+lUwB/IYvJ4sf5Nko0pw441kVpW9K+1MnLz hlEEQXP02htjRYdbm5gB0b5QYbmFGgjoNtxaxROZL6Xw1T/XqM3XUqIqlInG1uj+g7/f zfhP6fQqhN0T4wfzcFHs48KwN2wV8lF0F/grYpc/EJ6ysCSdctwWXF/1Dv/Qf/xkSfgj pIzgKfJztibOD58d/e5xGnsDzonPuTX1H9xNGQMU4NqC2G5TOMwOBH3SKhxoftSV5FVK f1j4n+dAuvVWKFl0UXuxgxxhjKau1CNoXK930Eln/rgCK6ExL4TSifqs5Byd9w8+21Op ekNQ==
Hi,
The first version is indeed wrong. This is because 'foo' appears on
both sides and it might happens that foo(0) is set to zero before it
is read to apply the inverse.
Your second version should be ok because you do not read foo(0) after
it has been changed, but that's still a dangerous use.
btw, instead of .block(1,0,2,1), you can use .segment(1,2) or even,
..segment<2>(1).
gael
On Thu, Apr 18, 2013 at 8:58 AM, Arnaud BARRE <arnaud.barre@xxxxxxxxx> wrote:
> I've recently updated my Mac to MacOS 10.8 and then by default the compiler
> used is Clang.
>
> During the running of unit tests in my program I discovered a specific issue
> with Clang. The same unit tests passed for GCC 4.2 and MSVC 2008.
>
> For example, I have the following code:
> Eigen::Matrix<double,4,1> foo;
> foo << I, 1.0;
> foo << 0.0, rot * (inv * foo).block(1,0,2,1), 1.0;
> *JC = (local * foo).block(0,0,3,1);
>
> The content of the line 3 is wrong with Clang, while there is no problem
> with the other compilers. If I modified the code with the following:
> Eigen::Matrix<double,4,1> foo;
> foo << I, 1.0;
> foo = inv * foo;
> foo << 0.0, rot * foo.block(1,0,2,1), 1.0;
> *JC = (local * foo).block(0,0,3,1);
>
> Then everything is fine. The difference is how 'foo' is used during the
> comma initialisation.
>
> In general is is a bad idea to use the first code for any compiler, or
> should I write a bug report for this case? I read in this ML than the
> delivered version of Clang for Mac has some problem but I didn't find any
> page on the website which list these issues. Maybe somewhere in the
> documentation it should be written to be carefull with Clang (delivered by
> Apple)?
>
> Arnaud