In my code I'm calculating an UInt64 value, then casting it like this:
return *(Cell*)packedUInt64;
Cell is a struct. Marshal.SizeOf(new Cell()) prints 8, so it should match an UInt64, but the cast above crashes with AccessViolationException. I could probably try safer methods such as Marshal.StructureToPtr, but I'm still wondering where's the error in my code? Maybe an alignment mismatch problem?