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 22765 - Assertion failure in CppMangleVisitor.template_args #15100

Merged
merged 1 commit into from
Apr 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion compiler/src/dmd/cppmangle.d
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,11 @@ private final class CppMangleVisitor : Visitor
foreach (j; i .. (*ti.tiargs).length)
{
Type t = isType((*ti.tiargs)[j]);
assert(t);
if (t is null)
{
ti.error("internal compiler error: C++ `%s` template value parameter is not supported", (*ti.tiargs)[j].toChars());
fatal();
}
t.accept(this);
}

Expand Down
14 changes: 14 additions & 0 deletions compiler/test/fail_compilation/test22765.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// https://issues.dlang.org/show_bug.cgi?id=22765

/*
TEST_OUTPUT:
---
fail_compilation/test22765.d(14): Error: template instance `test22765.Template!null` internal compiler error: C++ `null` template value parameter is not supported
Copy link
Member

Choose a reason for hiding this comment

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

Internal compiler errors should never be reachable, so this PR introduced a regression.

---
*/

template Template(T...)
{
extern(C++) const __gshared int Template = 0;
}
auto x = Template!(null);