[Mono-bugs] [Bug 641535] New: Wrong Marshal.SizeOf() for structs with explicity layout

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Thu Sep 23 23:00:14 EDT 2010


https://bugzilla.novell.com/show_bug.cgi?id=641535

https://bugzilla.novell.com/show_bug.cgi?id=641535#c0


           Summary: Wrong Marshal.SizeOf() for structs with explicity
                    layout
    Classification: Mono
           Product: Mono: Runtime
           Version: SVN
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: interop
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: gonzalo at novell.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---
           Blocker: ---


For the following test:
-------------------------
using System;
using System.Runtime.InteropServices;

class Test {
    [StructLayout (LayoutKind.Explicit, Size=12)]
    struct Twelve {
        [FieldOffset (0)]
        public int a;
        [FieldOffset (4)]
        public ulong b;
    }

    static void Main ()
    {
        Console.WriteLine (Marshal.SizeOf (typeof (Twelve)));
        StructLayoutAttribute att = typeof (Twelve).StructLayoutAttribute;
        Console.WriteLine ("Packing: {0} Size: {1}", att.Pack, att.Size);
    }
}
----------------------------
***
Output on windows (32 and 64 bits):
12
Packing: 8 Size: 12
***
Output on mono 32 bits:
12
Packing: 0 Size: 12
***
Output on mono 64 bits:
16
Packing: 0 Size: 12


If we explicitly set the packing to 1, the output in mono 64-bits is the
expected one, but MS seems to ignore "Pack" for explicit layouts.

-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list