Skip to content

Conversation

jkoritzinsky
Copy link
Member

Fixes #118196

@Copilot Copilot AI review requested due to automatic review settings July 31, 2025 17:26
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a bug in size calculation for derived explicit layout types that have no fields of their own. The issue was that when a class with explicit layout derives from another explicit layout class but doesn't define any fields, the size calculation was incorrectly starting from 0 instead of the parent class size.

Key changes:

  • Initialize size calculation with parent class size instead of 0 in classlayoutinfo.cpp
  • Add comprehensive test cases covering explicit layout inheritance scenarios

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/coreclr/vm/classlayoutinfo.cpp Fix size calculation initialization to use parent size instead of 0
src/tests/JIT/Methodical/structs/ExplicitLayout.cs Add test classes and methods to verify explicit layout inheritance behavior

@jkoritzinsky jkoritzinsky enabled auto-merge (squash) July 31, 2025 20:13
@jkoritzinsky jkoritzinsky merged commit 46648f3 into dotnet:main Aug 1, 2025
99 of 103 checks passed
@jkoritzinsky jkoritzinsky deleted the empty-explicit-derived branch August 1, 2025 04:01
@github-actions github-actions bot locked and limited conversation to collaborators Aug 31, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Regression in auto layout classes in .NET 10 preview 6
2 participants