[Mono-bugs] [Bug 52731][Wis] New - Invalid IL generated for GetFoo ().field were GetFoo () returns a struct

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Fri, 9 Jan 2004 23:21:55 -0500 (EST)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by bmaurer@users.sf.net.

http://bugzilla.ximian.com/show_bug.cgi?id=52731

--- shadow/52731	2004-01-09 23:21:55.000000000 -0500
+++ shadow/52731.tmp.22111	2004-01-09 23:21:55.000000000 -0500
@@ -0,0 +1,47 @@
+Bug#: 52731
+Product: Mono/Compilers
+Version: unspecified
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Wishlist
+Component: C#
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: bmaurer@users.sf.net               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Invalid IL generated for GetFoo ().field were GetFoo () returns a struct
+
+using System;
+
+class T {
+	static Foo GetFoo () { return new Foo (); }
+
+	static void Main ()
+	{
+		string s = GetFoo ().i.ToString ();
+		Console.WriteLine (s);
+	}
+}
+
+struct Foo { public int i; }
+
+Generates the IL:
+
+        IL_0000:  call valuetype 'Foo' class 'T'::'GetFoo'()
+        IL_0005:  ldflda  int32 'Foo'::'i'
+
+Which is invalid. Peverify complains:
+
+
+Microsoft (R) .NET Framework PE Verifier  Version 1.1.4322.573
+Copyright (C) Microsoft Corporation 1998-2002. All rights reserved.
+
+[IL]: Error: [c:\inetpub\ftproot\t.exe : T::Main] [offset 0x00000005]
+[opcode ldflda] [found value class 'Foo'] [expected address of value class
+'Foo'] Unexpected type on the stack.
+1 Errors Verifying t.exe