Compiler error

J

Jens Thiel

....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;
}
 
J

Jonathan Caves [MSFT]

From: "Jens Thiel said:
Subject: Compiler error
Date: Fri, 31 Oct 2003 11:52:34 +0100
...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;
}

Jens Thiel said:
...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;
}

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++;
i2[r,1] = i1;
i++;

I will ensure that this bug is fixed in the next release of the product:
 
J

Jens Thiel

...or what am I doing wrong with the the i++ increment operator?
i2[r,0] = i1[i++];
i2[r,1] = i1[i++];

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++;
i2[r,1] = i1;
i++;

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.
 
C

Carl Daniel [VC++ MVP]

Jens said:
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
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...

-cd
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top