[Mono-bugs] [Bug 74703][Min] New - Marshal.OffsetOf is broken in types with static fields

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Sat, 23 Apr 2005 13:30:23 -0400 (EDT)


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 danw@novell.com.

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

--- shadow/74703	2005-04-23 13:30:23.000000000 -0400
+++ shadow/74703.tmp.10556	2005-04-23 13:30:23.000000000 -0400
@@ -0,0 +1,44 @@
+Bug#: 74703
+Product: Mono: Runtime
+Version: 1.1
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Minor
+Component: misc
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: danw@novell.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Marshal.OffsetOf is broken in types with static fields
+
+ves_icall_System_Runtime_InteropServices_Marshal_OffsetOf doesn't take
+static fields into account properly. Given:
+
+struct Foo {
+    int a;
+    static int b;
+    long c;
+    static char d;
+    int e;
+};
+
+you get:
+
+    Marshal.OffsetOf (t, "a") == 0
+    Marshal.OffsetOf (t, "b") == 4
+    Marshal.OffsetOf (t, "c") == 12
+    Marshal.OffsetOf (t, "d") == semi-random number
+    Marshal.OffsetOf (t, "e") == semi-random number
+
+instead of the expected:
+
+    Marshal.OffsetOf (t, "a") == 0
+    Marshal.OffsetOf (t, "b") == exception
+    Marshal.OffsetOf (t, "c") == 4
+    Marshal.OffsetOf (t, "d") == exception
+    Marshal.OffsetOf (t, "e") == 12