The following program compiles fine bug generates an
ExecutionEngineException at runtime:
package TOBugJSharp;
import System.Decimal;
public class Buggy
{
/** @property */
public Decimal get_DecimalValue() { return new Decimal(1); }
public Object GetValue(boolean withCast)
{
return withCast ? (Object)get_DecimalValue() : get_DecimalValue();
}
/** @attribute System.STAThread() */
public static void main(String[] args)
{
Buggy buggy = new Buggy();
Object val = buggy.GetValue(true);
// instanceof triggers ExecutionEngineException!
if (val instanceof String)
System.out.println("string");
else
System.out.println("other: " + val);
}
}
Also, if you change it call buggy.GetValue(false) instead of
buggy.GetValue(true), it prints
other: null
which is also wrong (if you try val.getClass() , you get an NPE!)
So, it sounds that the compiler is generating buggy IL on the ternary
operator inside GetValue, my guess is that the Decimal is not boxed
correctly and then things go wild (but I am not an IL expert).
I tried it with Whidbey and the bug is still there. So, I will post it on
the whidbey site too.
Bruno.
wendy ferrari = maman75@hotmail.com - 08 Oct 2004 02:41 GMT
>-----Original Message-----
>The following program compiles fine bug generates an
[quoted text clipped - 41 lines]
>
>.
Amit Bhagwat [MSFT] - 10 Oct 2004 10:06 GMT
Hi Bruno,
Thanks for reporting this issue in the compiler. We will be fixing this
issue in the next release of VJ#.
Amit
--------------------
>From: "Bruno Jouhier [MVP]" <bjouhier@club-internet.fr>
>Subject: Serious bug on ternary operator: ExecutionEngineException
[quoted text clipped - 9 lines]
>NNTP-Posting-Host: l01v-23-55.d4.club-internet.fr 212.194.242.55
>Path:
cpmsftngxa06.phx.gbl!TK2MSFTNGXA03.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP14
.phx.gbl
>Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.vjsharp:6474
>X-Tomcat-NG: microsoft.public.dotnet.vjsharp
[quoted text clipped - 41 lines]
>
>Bruno.