<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
Thanks Arthur, 
<div class=""><br class="">
</div>
<div class="">This came up in the context of the HIP backend. The HIP release notes apparently mention that this is currently a bug (I don’t write code for HIP, but apparently HIP cannot access globals in device functions).  So while I don’t have a bug number
 I’m guessing that at least someone knows about it.  </div>
<div class=""><br class="">
</div>
<div class="">Incidentally, [x=x] is the workout around I just suggested to our users.  </div>
<div class=""><br class="">
</div>
<div class="">-Drew <br class="">
<div><br class="">
<blockquote type="cite" class="">
<div class="">On Oct 26, 2020, at 10:46 AM, Arthur O'Dwyer <<a href="mailto:arthur.j.odwyer@gmail.com" class="">arthur.j.odwyer@gmail.com</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div dir="ltr" class="">I confirm that this is a Clang bug, going back at least to Clang 6.  I don't know if it's been reported on
<a href="http://bugs.llvm.org/" class="">bugs.llvm.org</a> yet.
<div class=""><a href="https://godbolt.org/z/8419ss" class="">https://godbolt.org/z/8419ss</a><br class="">
</div>
<div class="">It doesn't matter whether the capture is done as [=] or as [x]. Doing it explicitly as [x=x] is a possible workaround.</div>
<div class=""><br class="">
</div>
<div class="">–Arthur</div>
<div class=""><br class="">
</div>
</div>
<br class="">
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Mon, Oct 26, 2020 at 1:26 PM Lewis, Cannada via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a>> wrote:<br class="">
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div style="overflow-wrap: break-word;" class="">Hello, 
<div class=""><br class="">
</div>
<div class="">We recently encountered an issue where clang has some unexpected behavior with respect to the capture of local references to global variables <a href="https://godbolt.org/z/KasP9K" target="_blank" class="">https://godbolt.org/z/KasP9K</a>.</div>
<div class=""><br class="">
</div>
<div class="">Most compilers (gcc, MSVC, icc) appear to create a member variable to hold the value of `myfoo` and have `dummy` return a size of 16.  Clang does not store a member for `myfoo` (in the AST there is no `FieldDecl` for `myfoo`). </div>
<div class=""><br class="">
</div>
<div class="">This leads to the interesting issue here: <a href="https://godbolt.org/z/G59e7M" target="_blank" class="">https://godbolt.org/z/G59e7M</a></div>
<div class="">Where clang and gcc will print out different values.  </div>
<div class=""><br class="">
</div>
<div class="">I don’t know if this is a clang issue (known?), or a {gcc,icc,msvc} issue, or is implementation defined, but any insight on this would be welcome.   </div>
<div class=""><br class="">
</div>
<div class="">-Drew </div>
</div>
_______________________________________________<br class="">
cfe-dev mailing list<br class="">
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank" class="">cfe-dev@lists.llvm.org</a><br class="">
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank" class="">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br class="">
</blockquote>
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
</body>
</html>