Search Issue Tracker

Fixed

Fixed in 2022.3.5f1, 2023.1.5f1, 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

--

-

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.0a22):

    Fixed field alignment of generic struct fields in il2cpp

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.