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

    <tr>
        <th>Summary</th>
        <td>
            False positive from `cplusplus.InnerPointer`
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

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

<pre>
    ```
#include <iostream>
#include <string>

const char* foo(int value) {
    thread_local std::string retval;

    retval = std::to_string(value);
    return retval.c_str();  // Pointer to inner buffer of 'std::string' obtained here
                            // Inner buffer of 'std::string' deallocated by call to destructor
                            // Inner pointer of container used after re/deallocation
}

int main(int argc, [[maybe_unused]] char* argv[]) {
    std::cout << foo(argc) << '\n';
}
```
The `thread_local` `std::string` is implicitly `static` so, the `const char*` will be valid for that thread until the next time the thread calls the function (and until the thread dies).
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVE2P4zYM_TX0hdhAkeM4PvgwM2mAAj30sPeBLNGxClkKJCrb_PtCtjczu22BNkgimOR7_HqWSslePVEPzSs050plnkLsv5L57eGvc6iGYB49HMX2FWcQLyBr67XLhhDqNxsSR1Iz1L_8kztxtP764Vz-dfCJUU8qgnzBMQSQJ-sZ78plAtkhtK9rJCIiT5GUeXdBK4eJDdQvUL-sxBiJ78pB_fqZv6BWB0J9_sBweN_qkafvuZ7QDZSj37A7XaJBntYoRJAXkBf8PVjPFJEDWu8p4pDHkSKGEUG2PxUIssUwsLKeDE4U6SPZv322NL_-J25DypXJMBkcHqiVc6UwQ4lj1hzi_8x325oLI-rgl7oj5kQG1VjskUBenklt8Nvc2_PnBZRlzsr6ba8qXjXIN1xU9jqrx0Dv2RdWaM7QnJ9SUPF6X6X4NxU8e9chc1EW1G-bdFb67rsRZAvNmy_HUxbP8n6U8teJEI7is8LgKIrp51EfBdqEdr45qy27xxqj2OriSqG0xyvbD-ou3m_WORyoyNsaHENEnhRvusbs2boF6-lPRrYzLU-bu2w0LYYxe10mjqVl_xm4hRpLCWS3q0xfm67uVEX9_tjWopPisK-m3hg6qq6TrR5lZ8ZakBGHtukOZhCnUVFleylkLfai3e8PrdzvZHPUbXcyrd6rRnYEB0Gzsm7n3H3ehXitbEqZ-qY7taJyaiCXlstESk_fcHGClOVuiX3BfBnyNcFBOJs4fbCwZUf9RblEeAvJsr0TjjHMy0BvLqfy2y0a3d4_OIoqR9dPzLdUdrXI-Gp5ysNOhxnkpdBvx5dbDH-QZpCXpagE8rIU_VcAAAD__yJChDI">