...or what am I doing wrong with the the i++ increment operator?
/*
compile with /clr
Output (compiled with VS.NET 2003, Framework 1.1) is:
r=0, i=0
r=1, i=0
r=2, i=0
*/
#include "stdafx.h"
#using <mscorlib.dll>
using namespace System;
int _tmain()
{
Int32 i1[] = { 1, 2, 3, 4, 5 ,6 };
Int32 i2[,] = new Int32[3, 2];
for( int i=0, r=0; r<3; r++ )
{
i2[r,0] = i1[i++];
i2[r,1] = i1[i++];
Console::WriteLine( String::Format(
S"r={0}, i={1}", r.ToString(), i.ToString() ) );
}
Console::ReadLine();
return 0;
}
Jonathan Caves [MSFT] - 31 Oct 2003 17:09 GMT
>From: "Jens Thiel" <jens@thiel.de>
>Subject: Compiler error
[quoted text clipped - 34 lines]
> return 0;
>}
> ...or what am I doing wrong with the the i++ increment operator?
>
[quoted text clipped - 31 lines]
> return 0;
> }
Jens: You're are doing nothing wrong: this is a compiler bug. The
work-around is to move the
increment operator out of the array access: for example:
i2[r,0] = i1[i];
i++;
i2[r,1] = i1[i];
i++;
I will ensure that this bug is fixed in the next release of the product:

Signature
Jonathan Caves, Visual C++ Team
This posting is provided AS IS with no warranties, and confers no rights.
Jens Thiel - 31 Oct 2003 18:50 GMT
> >...or what am I doing wrong with the the i++ increment operator?
> >
[quoted text clipped - 11 lines]
>
> I will ensure that this bug is fixed in the next release of the product:
Jonathan, the workaround was clear... Since I have plenty of existing code
which could be affected, I would be interested in the full coverage of this
bug. Do you have more information?
Is this fixed in the preview of Whidbey shipped through MSDN subscriptions?
Is it possible to get an updated version or hotfix of the 7.1 compiler
somewhere?
I have also hit other bugs that I found more or less documented in this
newsgroup (eg. virtual bool). There are also some strange and
non-deterministic problems with managed C++, IJW interop and JIT compilation
(no problem with NGENed images) which I am not able to reproduce out of the
project. And I have problems consuming attributes from managed C++ that were
written in managed C++. Oh well...
Jens.
Carl Daniel [VC++ MVP] - 31 Oct 2003 21:50 GMT
> Jonathan, the workaround was clear... Since I have plenty of existing
> code which could be affected, I would be interested in the full
> coverage of this bug. Do you have more information?
I can't comment on the scope of this bug - hopefully Jonathan or another VC
team member can provide more information on that.
> Is this fixed in the preview of Whidbey shipped through MSDN
> subscriptions? Is it possible to get an updated version or hotfix of
> the 7.1 compiler somewhere?
This bug does appear to be fixed in the alpha build of Whidbey. Hotfixes
are available by calling Microsoft product support - if there's a hotfix,
they'll know about it.
> I have also hit other bugs that I found more or less documented in
> this newsgroup (eg. virtual bool). There are also some strange and
[quoted text clipped - 3 lines]
> attributes from managed C++ that were written in managed C++. Oh
> well...
-cd