Re: [eigen] odd behaviour of operator[]

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


Tim Hutt wrote:
> 2009/6/18 Andre Krause <post@xxxxxxxxxxxxxxxx>:
>>        states[a, 0] = sin(0.1*a);
>>        states[a, 1] = sin(0.2*a);
>>        states[a, 2] = sin(0.3*a);
>> oddly enough, this code compiles fine and executes without asserts, but assigns
>> strange values to the array.
> 
> GCC gives a warning about the ',' operator having no effect. Due to
> operator precedence and stuff, the comma is evaluated and then the
> result of that comma is passed to the [] operator.
> 
> It is the equivalent of writing:  states[(a, 0)] = sin(0.1*a);
> Which is the same as:  a; states[0] = sin(0.1*a);
> 
> See http://msdn.microsoft.com/en-us/library/zs06xbxh(VS.80).aspx
> 
> 
> 

thanks , this makes sense. visual studio 2008 shows that warning, too, but only
if switched to max warning level, what i did now.

>c:\andre\c\esn\main.cpp(28) : warning C4709: comma operator within array index
expression




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