Compiler error

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jens Thiel

    #1

    Compiler error

    ....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::WriteL ine( String::Format(
    S"r={0}, i={1}", r.ToString(), i.ToString() ) );
    }

    Console::ReadLi ne();

    return 0;
    }


  • Jonathan Caves [MSFT]

    #2
    RE: Compiler error

    >From: "Jens Thiel" <jens@thiel.d e>[color=blue]
    >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::WriteL ine( String::Format(
    > S"r={0}, i={1}", r.ToString(), i.ToString() ) );
    > }
    >
    > Console::ReadLi ne();
    >
    > return 0;
    >}
    >
    >
    >[/color]

    "Jens Thiel" <jens@thiel.d e> wrote in message
    news:OIQK915nDH A.1096@TK2MSFTN GP11.phx.gbl...[color=blue]
    > ...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::WriteL ine( String::Format(
    > S"r={0}, i={1}", r.ToString(), i.ToString() ) );
    > }
    >
    > Console::ReadLi ne();
    >
    > return 0;
    > }
    >[/color]

    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:

    --
    Jonathan Caves, Visual C++ Team
    This posting is provided AS IS with no warranties, and confers no rights.

    Comment

    • Jens Thiel

      #3
      Re: Compiler error

      > >...or what am I doing wrong with the the i++ increment operator?[color=blue][color=green]
      > >
      > > i2[r,0] = i1[i++];
      > > i2[r,1] = i1[i++];[/color]
      >
      > 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:[/color]

      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.


      Comment

      • Carl Daniel [VC++ MVP]

        #4
        Re: Compiler error

        Jens Thiel wrote:[color=blue]
        > 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?[/color]

        I can't comment on the scope of this bug - hopefully Jonathan or another VC
        team member can provide more information on that.
        [color=blue]
        >
        > 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?[/color]

        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.
        [color=blue]
        >
        > 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...[/color]

        -cd


        Comment

        Working...