<feed xmlns='http://www.w3.org/2005/Atom'>
<title>slang.git/tests/compute/typedef-member.slang.expected.txt, branch master</title>
<subtitle>Making it easier to work with shaders</subtitle>
<id>https://git.yummers.dev/slang.git/atom?h=master</id>
<link rel='self' href='https://git.yummers.dev/slang.git/atom?h=master'/>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/'/>
<updated>2017-12-28T11:53:19+00:00</updated>
<entry>
<title>Fix NameExprType returning deleted canonical type when it's in a generic parent.</title>
<updated>2017-12-28T11:53:19+00:00</updated>
<author>
<name>Yong He</name>
<email>yonghe@outlook.com</email>
</author>
<published>2017-12-28T11:53:19+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=d46aeb030fa76854d2e7e64a25849b887defe4da'/>
<id>urn:sha1:d46aeb030fa76854d2e7e64a25849b887defe4da</id>
<content type='text'>
fixes #339

`NamedExpressionType::CreateCanonicalType()` may return a deleted pointer. The original implementation is as follows:
```
    Type* NamedExpressionType::CreateCanonicalType()
    {
        return GetType(declRef)-&gt;GetCanonicalType();
    }
```
If `GetType()` returns a newly constructed Type (this happens when the `typedef` is defined inside a generic parent, which triggers a non-trivial substitution), the temporary type will be deleted when the function returns. The fix is to store the temporary type as a field of NamedExpressionType (`innerType`).

A relevant fix (though not the true cause of issue #339) is to have `Type::GetCanonicalType()` also hold a `RefPtr` to the constructed canonical type, when the canonical type is not `this`. This prevents a returned canonical type being assigned to a RefPtr, which makes it possible for that RefPtr to be the sole owner of the canonical type and deleteing the canonical type when that RefPtr is destroyed.
</content>
</entry>
</feed>
