C# compiler BUG - const delegate assignment within a structure definition

There is a bug in the C# complirer which Visual Studio crashing. The bug happends when writing a const delegate assignment within the a structure. for example:

public struct Temp
{
private const Action<bool> Foo = delegate() { return false; };
}

I searched everywhere to find a link for a bug report. I even called the support team. Unfortunately I couldn't do it online because the the ActiveX control on the web site failed to locate the product id. I even tried it manually but it gives me "Invalid produc id" error.

I'm using VS2005 on Vista.

FYI, replacing the const with static will solve the problem.

Thanks,

/Ali

(mailto:alij@alcor.concordia.ca)




Answer this question

C# compiler BUG - const delegate assignment within a structure definition

  • acf

    The compiler was not updated with Visual Studio 2005 SP1--it's part of the framework, not VS...

  • Flakky

    Ernst Kuschke wrote:
    True! Though VS can "decide" which compiler to use for which solution type
    I suppose VS could pick a particular compiler to use; but, there isn't a released compiler that doesn't have this bug. Plus, it would have to cater Intellisense for the particular compiler. This bug may not cause a problem with Intellisense, but others would.



  • Lama Karmi

    Hi,

    I tried this on Orcas compiler and the ICE is not there but an error appears saying" A const field of a reference type other than string can only be initialized with null".

    This seems to be the solution to the bug, I don't know why the solution didn't make it to SP1.


  • VThornheart

    Great!, Thanks.
  • libyan

    True! Though VS can "decide" which compiler to use for which solution type Wink


  • donkaiser

    I can indeed reproduce this in VS2005 with SP installed, on WinXP Pro.


  • PSernz

    Thanks for your notes. My point is: although the const shouldn't be used for the declaration, the IDE shouldn't crash.

    BTW, I was able to send it as a feed back using the following link which I got from rgerbig.

    http://lab.msdn.microsoft.com/productfeedback/default.aspx

    Thanks.



  • C# compiler BUG - const delegate assignment within a structure definition