<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="">
I’m not a standards reading expert but does 
<div class=""><br class="">
<div class=""><i class="">Note <a href="https://eel.is/c++draft/expr.prim.lambda#capture-note-7" class="">7</a></i>:
<div id="capture-11.sentence-2" class="sentence">An <a href="https://eel.is/c++draft/expr.prim.id.general#nt:id-expression" title="7.5.4.1 General [expr.prim.id.general]" class="">
<span id="ntref:id-expression_____" class=""><span class="textsf"><i class="">id-expression</i></span></span></a> that is not an odr-use refers to the original entity, never to a member of the closure type<a class="hidden_link" href="https://eel.is/c++draft/expr.prim.lambda#capture-11.sentence-2">.</a></div>
<div id="capture-11.sentence-3" class="sentence">However, such an <a href="https://eel.is/c++draft/expr.prim.id.general#nt:id-expression" title="7.5.4.1 General [expr.prim.id.general]" class="">
<span id="ntref:id-expression______" class=""><span class="textsf"><i class="">id-expression</i></span></span></a> can still cause the implicit capture of the entity<a class="hidden_link" href="https://eel.is/c++draft/expr.prim.lambda#capture-11.sentence-3">.</a></div>
— <i class="">end note</i></div>
<div class=""><i class=""><br class="">
</i></div>
<div class="">From the text imply that the program <a href="https://godbolt.org/z/feKxdK" class="">
https://godbolt.org/z/feKxdK</a> is actually implementation defined? Or does gcc have a bug here? </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 4:33 PM, Hubert Tong <<a href="mailto:hubert.reinterpretcast@gmail.com" class="">hubert.reinterpretcast@gmail.com</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div dir="ltr" style="caret-color: rgb(0, 0, 0); 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; text-decoration: none;" 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-width: 1px; border-left-style: solid; border-left-color: 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>
</blockquote>
<div class="">N4861 subclause 7.5.5.2 [expr.prim.lambda.capture] paragraph 11 seems to apply. The local entity being captured is a reference and it is not odr-used (see [basic.def.odr] paragraph 4).<br class="">
</div>
<div class=""> </div>
<blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;">
<div style="overflow-wrap: break-word;" class="">
<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></blockquote>
</div>
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
</div>
</body>
</html>