{"id":97555,"date":"2017-12-11T07:00:00","date_gmt":"2017-12-11T22:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/?p=97555"},"modified":"2019-03-13T01:27:30","modified_gmt":"2019-03-13T08:27:30","slug":"20171211-00","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20171211-00\/?p=97555","title":{"rendered":"Coroutines mean that the thing that looks like a stack variable may not technically be one"},"content":{"rendered":"<p>Some time ago, <a HREF=\"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/20160728-00\/?p=93975\">I pointed out the <code>Get&shy;Current&shy;Thread&shy;Stack&shy;Limits<\/code> function<\/a> which lets you determine whether a  pointer points into the stack. <\/p>\n<p>Note, however, that if the local variable is captured by a coroutine, <a HREF=\"https:\/\/blogs.msdn.microsoft.com\/vcblog\/2015\/11\/30\/coroutines-in-visual-studio-2015-update-1\/\">The introduction of coroutines into the C++ language<\/a> means that what looks like a local variable may end up being hoisted into a heap-allocated object representing the coroutine itself (like, say, a <code>std::future<\/code>). <\/p>\n<p>Something to bear in mind if you&#8217;re going to be making decisions based on whether a variable is on the stack. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hoisted into the future.<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[25],"class_list":["post-97555","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>Hoisted into the future.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/97555","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=97555"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/97555\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=97555"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=97555"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=97555"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}