[Mono-dev] mcs bug

Jeroen Frijters jeroen at sumatra.nl
Wed Aug 2 16:42:05 EDT 2006


Hi,

I ran into a bug in mcs. The program below obviously should print 42,
but it prints 0, because mcs reuses loc.0 for two different things
within the same expression.

Regards,
Jeroen

using System;

class Repro
{
	private int[] stack = new int[1];
	private int cc;
	public int fc;
	private int sp;

	public static void Main()
	{
		Repro r = new Repro();
		r.foo();
		Console.WriteLine(r.stack[0]);
	}

	public void foo()
	{
		fc = cc = bar();
		fc = stack[sp++] = cc;
	}

	private int bar()
	{
		return 42;
	}
}



More information about the Mono-devel-list mailing list