Bugzilla – Bug 314417
[PATCH] We do not report CS0625
Last modified: 2007-09-15 21:24:23 UTC
---- Reported by vargaz@freemail.hu 2004-04-16 14:15:39 MST ---- mcs does not report the CS0625: Instance field types marked with StructLayout(LayoutKind.Explicit) must have a FieldOffset attribute. Testcase: <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< using System; using System.Runtime.InteropServices; [StructLayout(LayoutKind.Explicit)] struct GValue { public string name; [ FieldOffset (4) ] public int value; } [StructLayout(LayoutKind.Explicit)] struct GValue2 { public static int foo; } class Tests { public static void Main () { } } <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ---- Additional Comments From rharinath@novell.com 2004-05-04 07:41:31 MST ---- Created an attachment (id=165904) proposed fix ---- Additional Comments From bmaurer@users.sf.net 2004-05-04 08:14:51 MST ---- What about a `const' field. I am not sure that has the static flags. Is it an error to have a `FieldOffset' without the explicit flag being set? Maybe you should not `return' when you find one error. For the user, it would be nice if ALL fields that needed a FieldOffset caused an error with only one compilation. ---- Additional Comments From rharinath@novell.com 2004-05-05 05:54:15 MST ---- 'const' fields are not added to 'fields' AFAIK. I'll have to check on CSC if it allows FieldOffset on const fields. In general, though, we don't seem to support applying attributes on constants. I'll be posting an updated patch soon. ---- Additional Comments From rharinath@novell.com 2004-05-05 07:26:17 MST ---- Created an attachment (id=165905) updated proposed fix ---- Additional Comments From rharinath@novell.com 2004-05-05 07:56:31 MST ---- Created an attachment (id=165906) updated proposed fix (take 2) ---- Additional Comments From rharinath@novell.com 2004-05-07 08:00:42 MST ---- Created an attachment (id=165907) one more fix, including test for cs0636 ---- Additional Comments From rharinath@novell.com 2004-05-12 02:42:44 MST ---- Patch applied. Imported an attachment (id=165904) Imported an attachment (id=165905) Imported an attachment (id=165906) Imported an attachment (id=165907) Unknown operating system unknown. Setting to default OS "Other".