title: How to use P1787 to interpret why the static local variable in inline function refers to the same object
body: <p><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p1787r5.html" rel="nofollow noreferrer">P1787</a> has an excellent description for what are the same entity.</p>
  <blockquote>
  <p>Two declarations of entities declare the same entity if, considering declarations of unnamed types to introduce their names for linkage purposes, if any ([dcl.typedef], [dcl.enum]), they correspond ([basic.scope.scope]), have the same target scope that is not a function or template parameter scope, and either</p>
  <blockquote>
  <ol>
  <li>they appear in the same translation unit, or</li>
  <li>they both declare names with module linkage and are attached to the same module, or</li>
  <li>they both declare names with external linkage.</li>
  </ol>
  </blockquote>
  </blockquote>
  <p>So, consider this example:</p>
  <pre class="lang-cpp prettyprint-override"><code>// a.hpp
  inline int&amp; function(){
     static int value = 0; // #1
     return value;
  }
  ----------------------
  //b.cpp
  #include &quot;a.hpp&quot;
  void g(){
    auto&amp;&amp; rf = function();
  }
  ----------------------
  //c.cpp
  #include &quot;a.hpp&quot;
  int main(){
   auto&amp;&amp; rf0 = function();
  }
  </code></pre>
  <p>Except for the note says that:</p>
  <blockquote>
  <p>[ Note: An inline function or variable with external or module linkage can be defined in multiple translation units([basic.def.odr]), but is one entity with one address. A type or variable defined in the body of such a function is therefore <strong>a single entity</strong>.--end note]</p>
  </blockquote>
  <p>However, let's consider the <code>value</code> declared at <code>#1</code>. In <code>b</code>'s TU and <code>c</code>'s TU, these two declarations for <code>value</code> are corresponding, and they have the same target scope which is introduced by the compound-statement of <code>function</code>. However, a local variable does not have any linkage, so neither bullet in that list will be satisfied. So, why two declarations for <code>value</code>(in the body of the function) in different two translate units declared the same entity? How to interpret that through the rule in P1787?</p>