Fix Issue 22739 - Segmentation fault in CppMangleVisitor.headOfType (#15098)

This commit is contained in:
Razvan Nitu 2023-04-13 18:11:04 +03:00 committed by GitHub
parent 997b00bf45
commit bd23d5972b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 0 deletions

View file

@ -213,6 +213,11 @@ private final class CppMangleVisitor : Visitor
{
auto tf = cast(TypeFunction)this.context.res.asFuncDecl().type;
Type rt = preSemantic.nextOf();
// https://issues.dlang.org/show_bug.cgi?id=22739
// auto return type means that rt is null.
// if so, just pick up the type from the instance
if (!rt)
rt = tf.nextOf();
if (tf.isref)
rt = rt.referenceTo();
auto prev = this.context.push(tf.nextOf());

View file

@ -0,0 +1,10 @@
// https://issues.dlang.org/show_bug.cgi?id=22739
extern(C++) auto f(T)()
{
return T.init;
}
void main()
{
f!int;
}