<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=""><br class=""><div><blockquote type="cite" class=""><div class="">On 17 Apr 2017, at 21:18, Anders Kierulf &lt;<a href="mailto:anders@smartgo.com" class="">anders@smartgo.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><br class=""></div><div class=""><blockquote type="cite" class=""><div class="">On Apr 17, 2017, at 12:37 PM, Karl Wagner &lt;<a href="mailto:razielim@gmail.com" class="">razielim@gmail.com</a>&gt; wrote:</div><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On 17 Apr 2017, at 19:52, Anders Kierulf via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Proposal: UnsafeMutablePointer almost provides what I need. However, it can only allocate memory on the heap, or it can take a given blob of memory and interpret it as something else. What’s missing is a way to allocate typed memory of a certain size on the stack or in a struct. For example, something like this, with support for subscripts, limited to value types:</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""></div></blockquote></div><br class=""><div class="">What happens if you use alloca?</div></div></div></blockquote></div><br class=""><div class="">Doesn’t look like using alloca is recommended in Swift: <a href="https://bugs.swift.org/browse/SR-323" class="">https://bugs.swift.org/browse/SR-323</a></div><div class=""><br class=""></div><div class="">Also, while it might be used as a hack for stack allocations, it wouldn’t allow inclusion into structs.</div><div class=""><br class=""></div><div class="">Anders</div></div></div></blockquote></div><br class=""><div class="">Huh. That’s weird. I figured in your case, with an integer literal, there shouldn’t really be any difference between alloca(19*19) and a stack-allocated, fixed-size array like char[19 * 19].</div><div class=""><br class=""></div><div class="">alloca is usually a compiler intrinsic (I suppose that’s why the linker isn’t going to find it). It’s definitely a SIL intrinsic. Maybe those two just aren’t wired up correctly to support user-code calling “alloca”.</div><div class=""><br class=""></div><div class="">Could certainly be supported - we should probably support alloca directly (as we do for malloc), and we could provide a function on UMP which does the same thing (allocateNonEscaping?)</div><div class=""><br class=""></div><div class="">- Karl</div></body></html>