<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/64811>64811</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            `inline` variable initializers inconsistently put closure types into block scopes
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          Eisenwave
      </td>
    </tr>
</table>

<pre>
    ```cpp
inline decltype([]{}) x = {};
inline auto y = decltype([]{}){};
inline auto z = []{};

[[gnu::used]] void foo(decltype(x)) {}
[[gnu::used]] void bar(decltype(y)) {}
[[gnu::used]] void baz(decltype(z)) {}
```
This produces (with demangled identifiers) (https://godbolt.org/z/Kj8hq4K9M):
```asm
foo($_0):
 ret
bar($_1):
        ret
baz(z::{lambda()#1}):
 ret
```
For some reason, the closure type corresponding to the lambda expression which initializes `z` is scoped to `z`, instead of being in global scope like the other closure types.

This makes no sense because inline variable initializers don't introduces a block scope in the first place (see [[basic.scope.block] p1](https://eel.is/c++draft/basic.scope.block#1)
> The closure type is declared in the smallest block scope, class scope, or namespace scope that contains the corresponding [lambda-

\- [[expr.lambda.closure] p2](https://eel.is/c++draft/expr.prim.lambda.closure#2)

According to this paragraph, the closure type should be scoped just like that of `x` and `y`, in global scope.

It's possible that this mistake is the result of misinterpreting [[basic.def.odr] p14.4](https://eel.is/c++draft/basic.def.odr#14.4), which is not defining behavior, and merely requiring it. 
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycVVFvozgQ_jXOi1UEJgnwkIdmu5FOq3vb95OxhzCtsVmPaZv8-pMN2SbZ3un2qooC_eabmW--MZIIjxZgxzZ7tnlaySn0zu--IoF9k6-wap0-7dg2n3_VOLL8ieWPaA1a4BqUCacRmKhnAlbtWfXERMPfOSuf-PJc7m_C5BQcPyXAPzP8S-h55r7GX2DLNf5rf7QTKx9Z-TgR6AjdP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