Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Issue 22760 - Segmentation fault in CppMangleVisitor.template_arg #15099

Merged
merged 1 commit into from
May 5, 2023

Conversation

RazvanN7
Copy link
Contributor

For aggregate declarations at the template level the parent is not the template instance but the aggregate. For example:

struct T(U)
{
      struct S {}
}

For a given instantiation, say T!int, the parent of S is not T!int but T!int.T. That is because the compiler rewrites the struct to an eponymous template. That is why, in this PR, I am checking the parent of parent for writing the cpp mangled name. I am keeping the old case because there are situations such as:

template T(U)
{
     int a;
     struct T {}
}

In this case, the parent of a is going to be T!whatever, not T!whatever.T.

@Geod24 can you please take a look at this, since you are the original author? I don't particularly like this fix, it looks like a special case handling, however, I have no idea if a better fix is possible.

@dlang-bot
Copy link
Contributor

Thanks for your pull request and interest in making D better, @RazvanN7! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the coverage diff by visiting the details link of the codecov check)
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

Please see CONTRIBUTING.md for more information.


If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.

Bugzilla references

Auto-close Bugzilla Severity Description
22760 critical Segmentation fault in CppMangleVisitor.template_arg

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 "stable + dmd#15099"

Copy link
Contributor

@dkorpel dkorpel left a comment

Choose a reason for hiding this comment

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

@dkorpel
Copy link
Contributor

dkorpel commented May 2, 2023

@RazvanN7 Can you rebase to rerun tests, or force merge at some point?

@RazvanN7
Copy link
Contributor Author

RazvanN7 commented May 2, 2023

@dkorpel done

@RazvanN7 RazvanN7 merged commit 4a4adcd into dlang:stable May 5, 2023
@ibuclaw ibuclaw mentioned this pull request May 16, 2023
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.

4 participants