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

    <tr>
        <th>Summary</th>
        <td>
            Attribute clang::lifetimebound produces no warning when assign temporary's address to pointer declared before.
        </td>
    </tr>

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

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

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

<pre>
    [[clang::lifetimebound]] could be used to provide some lifetime annotation to functions. In the statement of a pointer initialization, everything works fine. But in the statement of a pointer assignment, the desired warning can not be produced.

Here is the code sample:
```c++
#include <string>

const char* get(const std::string& s [[clang::lifetimebound]]){
    return s.data();
}

int main(){
 // can be detected
 const char* s1 = get("hello"s);

 // cannot be detected
 const char* s2 = nullptr;
 s2 = get("hello"s);

 return 0;
}

```

Is this intentional or a flaw of lifetime check?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyNVNtu2zAM_Rr5hZjhyHbSPPghbVas2FfIEm2rVaRAlwbd14-ynawd0KIBE9skdUgenrh36q1j7T2ZNMKOrD6QGT1g1CfsXbKKtUcykC4ZBT1CCqggOjh796oVQnAnhOsJENa6KKJ2NucMycp8H0p4IsdE2RTEE9oIbgABZ6dtRA_a6qiF0X_mo4w_AL6if4uTtiNcnH8JMGiLJdynSMlfQYkQ9GizP8PkRIVBe2r6IrzNeFJYoC7zMDSEShJVyaojqw7L7y_0CDrMZ6XLI4rT2WDmZsnaVotJxu-zLV5eaytNonxWP4Todabz53tgSUxEkJPwjB9gROrwbvGFqBbq13N8CwG-sxfG92y3dgD08RiTtxBKJaIg-Byvrx3uju-7IbrgJLRds24ojD-SzSz1mbyIMqJagx9HCBua9bhOwjif0BhH1_Ch7P-wK_dfI_MZ2SZjztHfsK7-b1Vcuag-I-C2x_fOp7x3Wn4Wk81iFAYcqQoGIy5ZaTepywnlC6sfC9XVal_vRRF1NNgdIu2wT5EyPlndVXaBZHhT5WVCu4oXSNdn54V_Y3wXQCjlMYT5T7eKXCFhZ033ODiPZZG86aYYzyGXm5kedZxSX0p3ogdjXq-XH1T8mYinRx1CQmLusW2aPS-mbrNTsmqHodruNpt2V0vVynYnhRTbpmqbqjCiRxPmNwbnFi8wQ9A9SbHQHa84r-r8rfe8Le_UUN01m6oaRMOVQNZUSIozZe6jdH4sfDe31KcxUNDoEMO_4EIG4vKCOhYixcn57rdWIdneFXPtbu79L1Q3fso">