<div dir="ltr">Ok, thanks! </div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Dec 13, 2017 at 10:20 PM, Andrew Trick <span dir="ltr"><<a href="mailto:atrick@apple.com" target="_blank">atrick@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Yes, withExtendedLifetime is a generic API that guarantees the lifetime of any non-trivial value. i.e. if the tuple contains a reference, the lifetime of that reference will be extended.<br>
<br>
That said, there is a theoretical bug in the optimizer that you will be much more likely to hit in practice if you pass a tuple to this API. I still think it’s extremely unlikely that the code will be miscompiled though, and I’m sure it will be fixed shortly ;)<br>
<br>
<a href="https://bugs.swift.org/browse/SR-6608" rel="noreferrer" target="_blank">https://bugs.swift.org/browse/<wbr>SR-6608</a>: DeadCodeElimination removes fix_lifetime<br>
<br>
-Andy<br>
<div class="HOEnZb"><div class="h5"><br>
> On Dec 13, 2017, at 10:05 AM, Jordan Rose <<a href="mailto:jordan_rose@apple.com">jordan_rose@apple.com</a>> wrote:<br>
><br>
> Good question and good thought! I believe the answer is yes, this will work as intended, but I'd like to get someone more versed in SIL than me to verify that. Andy?<br>
><br>
> Jordan<br>
><br>
><br>
>> On Dec 13, 2017, at 01:28, Jens Persson via swift-users <<a href="mailto:swift-users@swift.org">swift-users@swift.org</a>> wrote:<br>
>><br>
>> There are no restrictions on the type of the first argument to withExtendedLiftetime, even though it makes sense only for reference types.<br>
>><br>
>> So both the below variants will compile, and my question is if the first one will work as expected (extending the lifetime of both a and b) or if the second variant must be used instead.<br>
>><br>
>> 1:<br>
>> withExtendedLifetime((a, b)) {<br>
>> ...<br>
>> }<br>
>><br>
>> 2:<br>
>> withExtendedLifetime(a) {<br>
>> withExtendedLifetime(b) {<br>
>> ...<br>
>> }<br>
>> }<br>
>><br>
>> /Jens<br>
>><br>
>> ______________________________<wbr>_________________<br>
>> swift-users mailing list<br>
>> <a href="mailto:swift-users@swift.org">swift-users@swift.org</a><br>
>> <a href="https://lists.swift.org/mailman/listinfo/swift-users" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-users</a><br>
><br>
<br>
</div></div></blockquote></div><br></div>