<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/87229>87229</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang cannot detect any of the lifetime issue here but GCC can
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
trcrsired
</td>
</tr>
</table>
<pre>
https://learn.microsoft.com/en-us/cpp/sanitizers/error-stack-use-after-scope?view=msvc-170
```cpp
int *gp;
bool b = true;
int main() {
if (b) {
int x[5];
gp = x+1;
}
return *gp; // Boom!
}
```
clang (no warnings):
https://godbolt.org/z/qab3nP38f
gcc:
https://godbolt.org/z/Porf9Mejj
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMUsuOnDAQ_JrmYjHCDQzDgcPOjsgp0v6CMQ3jjbGJ3ezr6yNgdlabXCIhIVd3V7XLpWI0oyNqoDxDeUnUwlcfGg46RBOoTzrfvzdX5jlC_gDYAraWVHCHyejgox_4oP0E2JJLlwjY6nkGbKNyhs0HhRWiEHxIIyv9K10ipWpgCmnUfibI2xdDr5BfpviiU1llkF0ge4Bjtn8r3YYYxwLwYZwhP-9I570VnYD8IjgsdMfXzkkZB3gCrAVUN1wIIcwgAE_dP_hWcyzeoDyXUF7uZJ_Fcd6E3gDP8lsRqsvXIRAvwd33FGJ3TJz96pG83e1z4n7J_aitcuO6nvPiVQVn3BgB69X3rf79FUbfd97ywYcRsP0AbH-rLndP-WnY20et_3v0yYeh_knPz0nf5H2d1yqhRlZS1pWUpUyuTTagxAKVrutKlbLHKssGmRfl8SiLgXRiGsywyIpMSpmjrA-6OPaVovqkS5Ja5VBkNCljD9a-TKt2YmJcqDlViHViVUc2bjFE3JwAxDWRoVn7024ZIxSZNZHjFwMbttTsxmnlnGfRE5Nmody78IPgKwlrBmIzkdj0xJUCiW5h8ePxcR1KlmD_Svho-Lp0t2CvYrdfOgf_TJoB241rDfe2_p8AAAD__6bD9qw">