Skip to content

Conversation

@hahnjo
Copy link
Member

@hahnjo hahnjo commented Jan 27, 2026

The assumption is that serialized declarations must be valid, however that doesn't hold anymore in the presence of static_assert in templated classes.

Fixes #20638

The assumption is that serialized declarations must be valid, however
that doesn't hold anymore in the presence of static_assert in templated
classes.

Fixes root-project#20638
@hahnjo hahnjo self-assigned this Jan 27, 2026
@hahnjo hahnjo requested a review from dpiparo as a code owner January 27, 2026 12:32
if (D->isFromASTFile()) {
// We cannot ignore instantiated CXXMethodDecl's in templated classes:
// They may have failing static_assert.
if (auto* M = dyn_cast<CXXMethodDecl>(D)) {
Copy link
Member

Choose a reason for hiding this comment

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

Is that change sufficient for these things to be reinstantiated? In particular, non-static_assert method decls coming from ast files? We should probably add some tests.

Copy link
Member

Choose a reason for hiding this comment

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

This could be relatively easy, right? If I understand correctly we need a template broghut into memory from a pcm and then 2 instantiations in a row - please correct me if I am wrong.
If the above is correct, and this cannot be put in cling since we need a dictionary, we can comfortably put the test in roottest, maybe even profiting from ROOT helpers that at runtime allow us to generate dictionaries on the fly

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, Dev has a test case (in roottest) for the problem I'm trying to solve. We don't have a (new) test for an unloaded method that does not have a static_assert (I believe that's what Vassil is asking about). It's probably covered by other tests, but I need to check. Moreover there are two failing tests (roottest-cling-reload-reloadvector and roottest-root-tree-selector-selector) that I don't have locally...

Copy link
Member

Choose a reason for hiding this comment

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

Yes, having tests in cling is better because when we break this it's far easier to debug. The test does not need a dictionary. We need a module file with a static assert declaration.

Copy link
Member Author

Choose a reason for hiding this comment

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

We don't have a single test using modules / pcm's in interpreter/cling/test and I'm not going to invent the infrastructure for this PR. The test is going to go into roottest.

Copy link
Member

Choose a reason for hiding this comment

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

Thank you for being constructive. In that case please hold off merging this PR until I provide you with the infrastructure (which is 3 lines).

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok.

Copy link
Member

Choose a reason for hiding this comment

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

In fact the infrastructure seems to be there already. Please take a look at cling/test/CodeUnloading/PCH/. We should be able to extend some of these tests to cover that case, too.

@github-actions
Copy link

Test Results

    22 files      22 suites   3d 15h 39m 15s ⏱️
 3 773 tests  3 771 ✅ 0 💤  2 ❌
75 932 runs  75 921 ✅ 0 💤 11 ❌

For more details on these failures, see this check.

Results for commit f83ce07.

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.

This PR needs the appropriate test in cling. I will provide the infrastructure in the next week or so.

@hahnjo hahnjo marked this pull request as draft January 28, 2026 09:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[cling] Able to call function with failing static_assert on second try

3 participants