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
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- [iOS] Back Triple Camera is not focusing manually and automatically
- Mouse inputs cannot be inputted when searching the Shortcuts Menu by type "Shortcut"
- "Debug Assertion Failed!" error when launching Windows Dedicated Server Player with Script Debugging enabled
- [Cinematic Studio][3D HDRP] Shader warnings thrown in the Console window when creating a new project with Cinematic Studio template
- Autoplay is triggered on Audio Assets when changing Asset Bundle tags
Resolution Note (fix version 2023.2.0a22):
Fixed field alignment of generic struct fields in il2cpp