Skip to content

InlineArray reports wrong size when struct size is specified #110962

@hez2010

Description

@hez2010

Description

InlineArray reports wrong size when struct size is specified.

Reproduction Steps

Console.WriteLine(Unsafe.SizeOf<S>());

[InlineArray(length: 2)]
[StructLayout(LayoutKind.Sequential, Size = 42)]
struct S { byte item; }

Expected behavior

42

This should be equivalent to

Console.WriteLine(Unsafe.SizeOf<S>());

[StructLayout(LayoutKind.Sequential, Size = 42)]
struct S { byte item1, item2; }

Actual behavior

84

Regression?

No

Known Workarounds

No

Configuration

No response

Other information

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions