Skip to content

[rootcling] Remove check for unique_ptr members#20389

Merged
hahnjo merged 2 commits intoroot-project:masterfrom
hahnjo:unique_ptr-zero
Nov 12, 2025
Merged

[rootcling] Remove check for unique_ptr members#20389
hahnjo merged 2 commits intoroot-project:masterfrom
hahnjo:unique_ptr-zero

Conversation

@hahnjo
Copy link
Member

@hahnjo hahnjo commented Nov 12, 2025

Since llvm/llvm-project@f5e687d libc++ implements _LIBCPP_COMPRESSED_PAIR with an anonymous struct (a Clang extension). This results in unique_ptr having a single FieldDecl with an empty name that does not appear as a data member in TClass. Instead, the AST has multiple IndirectFieldDecls that "refer" into the anonymous struct.

In ROOT, we now have two options: We could support anonymous structs, either by allowing data members with empty names or by adding all indirect field declarations as members. However, I would argue that we actually do NOT want to support this extension for IO classes. Instead remove the (questionable) check in rootcling that verifies the number of data members in unique_ptr.

Closes #20377

Since llvm/llvm-project@f5e687d
libc++ implements _LIBCPP_COMPRESSED_PAIR with an anonymous struct (a
Clang extension). This results in unique_ptr having a single FieldDecl
with an empty name that does not appear as a data member in TClass.
Instead, the AST has multiple IndirectFieldDecl's that "refer" into
the anonymous struct.

In ROOT, we now have two options: We could support anonymous structs,
either by allowing data members with empty names or by adding all
indirect field declarations as members. However, I would argue that
we actually do NOT want to support this extension for IO classes.
Instead remove the (questionable) check in rootcling that verifies
the number of data members in unique_ptr.
Since the previous commit, IsUnsupportedUniquePointer does not check
the number of data members anymore.
Copy link
Member

@pcanal pcanal left a comment

Choose a reason for hiding this comment

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

Thanks for the investigation.

We could support anonymous structs, either by allowing data members with empty names or by adding all indirect field declarations as members. However, I would argue that we actually do NOT want to support this extension for IO classes.

We should probably (also) document/memorialize that we do not support this case (i.e. it 'could' affect some user code).

Side note that the real/essential check is already done by IsUniquePtrOffsetZero (i.e. support for unique_ptr requires that it is (strictly) using the same memory layout as a raw pointer).

Copy link
Member

@vgvassilev vgvassilev left a comment

Choose a reason for hiding this comment

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

Less is more! Nice, Lgtm!

@github-actions
Copy link

Test Results

    22 files      22 suites   3d 23h 23m 12s ⏱️
 3 749 tests  3 749 ✅ 0 💤 0 ❌
80 527 runs  80 527 ✅ 0 💤 0 ❌

Results for commit 10fa16d.

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.

Investigate I/O of std::unique_ptr on latest MacOS beta

3 participants

Comments