Search Issue Tracker

Fixed in 2022.3.5f1

Fixed in 2022.3.X, 2023.1.X, 2023.2.X, 2023.2.0a22

Votes

1

Found in

2022.3.2f1

2023.1.0f1

2023.2.0a20

Issue ID

UUM-40355

Regression

Yes

UnsafeUtility.AlignOf<T>() reports incorrect value for Explicit layout structs when building with IL2CPP backend

IL2CPP

-

Reproduction steps:
1. Open project “AlignOfBugReport.zip”
2. Enter Play Mode and observe “Align of test struct: 4” text displayed in Game view
3. Build and Run (might need to disable “Create Xcode Project” in the Build Settings first)
4. Observe Player

Expected result: “Align of test struct: 4” text is displayed
Actual result: “Align of test struct: 1” text is displayed

Reproducible with: 2022.2.0b8, 2022.3.2f1, 2023.1.0f1, 2023.2.0a20
Not reproducible with: 2021.3.27f1, 2022.2.0b7

Reproducible on: macOS Ventura 13.2.1 (Intel)

Notes:
- The correct value is reported in the Editor
- Changing the BugStruct definition from “{{LayoutKind.Explicit}}” to “{{LayoutKind.Sequential}}" in “AlignOfBug.cs” at line 4, while commenting out {{[FieldOffset(0)]}} at line 8 and {{[FieldOffset(4)]}} at line 9 gives expected results

  1. Resolution Note (fix version 2023.2):

    Fixed field alignment of generic struct fields in il2cpp

Add comment

Log in to post comment