Skip to content

Conversation

WalterBright
Copy link
Member

Fixes Issue #10840

This fix is blocking dlang/dmd#21625

@dlang-bot
Copy link
Contributor

Thanks for your pull request, @WalterBright!

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

⚠️⚠️⚠️ Warnings ⚠️⚠️⚠️

  • In preparation for migrating from Bugzilla to GitHub Issues, the issue reference syntax has changed. Please add the word "Bugzilla" to issue references. For example, Fix Bugzilla Issue 12345 or Fix Bugzilla 12345.(Reminder: the edit needs to be done in the Git commit message, not the GitHub pull request.)

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "master + phobos#10851"

@WalterBright
Copy link
Member Author

@ibuclaw please review and merge.

Comment on lines +2552 to +2555
* However, the overlap
* check in general does not take into account staggered unions.
* This can be fixed using the correct algorithm implemented in
* the compiler function dmd.declaration.isOverlappedWith().
Copy link
Member

Choose a reason for hiding this comment

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

FYI tracking this issue with staggered unions in #10844

Copy link
Member Author

Choose a reason for hiding this comment

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

good!

{
static if (i == T.tupleof.length - 1 || T.tupleof[i].offsetof != T.tupleof[i+1].offsetof)
static if (i == T.tupleof.length - 1 ||
T.tupleof[i ].offsetof * 8 + __traits(getBitfieldOffset,T.tupleof[i ]) !=
Copy link
Member

Choose a reason for hiding this comment

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

I didn't realise getBitfieldOffset worked for non-bitfields.

Copy link
Member Author

Choose a reason for hiding this comment

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

I implemented it that way for exactly this reason! It greatly simplifies the overlap logic. You'll see the same thing in the dmd source code, as referenced.

@WalterBright WalterBright merged commit db880b4 into dlang:master Aug 27, 2025
9 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants