<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">This reminds me of my previous question&nbsp;<a href="https://lists.swift.org/pipermail/swift-users/Week-of-Mon-20170220/004841.html" class="">https://lists.swift.org/pipermail/swift-users/Week-of-Mon-20170220/004841.html</a></div><div class=""><br class=""></div><div class=""><blockquote type="cite" class=""><pre style="white-space: pre-wrap; background-color: rgb(255, 255, 255);" class="">Is that simplified guaranteed to work? The Swift book says that

&gt;<i class=""> As an optimization, when the argument is a value stored at a physical address in memory, the same memory location is used both inside and outside the function body.
</i>
but also 

&gt;<i class=""> Write your code using the model given by copy-in copy-out, without depending on the call-by-reference optimization, so that it behaves correctly with or without the optimization.
</i>
If `tmp.0` is copied to a separate location then `String(cString: &amp;tmp.0)` would not work correctly, or would it?</pre></blockquote><div class=""><br class=""></div></div><div class="">to which Quinn responded&nbsp;<a href="https://lists.swift.org/pipermail/swift-users/Week-of-Mon-20170220/004842.html" class="">https://lists.swift.org/pipermail/swift-users/Week-of-Mon-20170220/004842.html</a></div><div class=""><br class=""></div><div class=""><blockquote type="cite" class=""><pre style="white-space: pre-wrap; background-color: rgb(255, 255, 255);" class="">Based on a previous conversation I had with the Swift folks about this, yes.

However, I don’t work on the compiler so it’s possible I misunderstood.  Perhaps someone from SwiftLand™ will chime in here.</pre></blockquote><div class=""><br class=""></div></div><div class="">Some authoritative response from&nbsp;<span style="white-space: pre-wrap; background-color: rgb(255, 255, 255);" class="">SwiftLand™ would be much appreciated.</span></div><div class=""><span style="white-space: pre-wrap; background-color: rgb(255, 255, 255);" class=""><br class=""></span></div><div class=""><span style="white-space: pre-wrap; background-color: rgb(255, 255, 255);" class="">Regards, Martin</span></div><div class=""><br class=""></div><br class=""><div><blockquote type="cite" class=""><div class="">On 19. Apr 2017, at 09:16, Quinn The Eskimo! via swift-users &lt;<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div class=""><br class="">On 19 Apr 2017, at 02:11, Rick Mann via swift-users &lt;<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>&gt; wrote:<br class=""><br class=""><blockquote type="cite" class="">In my C-interop, I have a need to do this a lot:<br class=""></blockquote><br class="">I think you’re working too hard here. &nbsp;Try this:<br class=""><br class="">func callbackFailed(info inInfo: lgs_result_info_t) {<br class=""> &nbsp;&nbsp;var m = inInfo.message<br class=""> &nbsp;&nbsp;let message = String(cString: &amp;m.0)<br class=""> &nbsp;&nbsp;debugLog("Failed: \(message)")<br class="">}<br class=""><br class="">Alas, you still need to do the copy in order to take the address of `m`.<br class=""><br class="">Share and Enjoy<br class="">--<br class="">Quinn "The Eskimo!" &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;<a href="http://www.apple.com/developer/" class="">http://www.apple.com/developer/</a>&gt;<br class="">Apple Developer Relations, Developer Technical Support, Core OS/Hardware<br class=""><br class=""><br class="">_______________________________________________<br class="">swift-users mailing list<br class=""><a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-users<br class=""></div></div></blockquote></div><br class=""></body></html>