<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/60503>60503</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Clang permits `int x = x`
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang:frontend
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
cjdb
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
cjdb
</td>
</tr>
</table>
<pre>
The following program should issue a diagnostic:
```cpp
int main()
{
int x = x;
}
```
I think this is a serious enough problem to be an error by default, even if it's well-formed per C and C++. I am not sure if the following is an exception, but it's at least weird?
```cpp
int main()
{
void* ptr = &ptr;
}
```
Clang Tidy catches this, but Clang really ought to as well.
Repro: https://godbolt.org/z/81andM3jb
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUksuOozwQhZ-m2JQ6cuwEkgWLXITUi3_zq1_AxgW4x9jILro78_QjctFkejUjIQMu6nDq89E5uz4Q1bA9gpTtuzUgJWzPhZ55iKledgoT7aV-Gwi76H38dKHHKcU-6RHzEGdv0eU8E2q0TvchZnYtqAOIM4gDlOJ2tdN023GBcdQugNyB3N-_qo63B1yqXwjqjF-gjo_q-ZvY_fW6viIPLvxY1owuo8ZMycU5I4U498Ni1ngakSMaQh2QUooJzQUtdXr2DPKE9EEBXYeOQVYZP8n7ly6mkSxOlPCEOlg8gTyCPK7wFfWIITLmOdHSxn_gWVwEpK-WJnYxLPpm5oe2ZvSkM-MnuWRBNc_T_Csv_IjOgjzgxOmKDWQ5cfpLdievQ49vzl6w1dwOlK8YH4Zv5UTa-wsuLHmBqG94Vs9C_9OUIqgDDsxTXk5fNiCbPloTPa9i6kE2P0E2u7UO9j_1bgpbK7tXe11QvS6r7UZUci2KoaZqpzZdVxkjS7GT-73aGGlLsak6s26tKFwthVRCCiXKrVJiVVU7VVra20poMlUJG0Gjdn7l_ce4_Lu4BrQuxVaowmtDPj8iv0wI6tClGJiCvcc_1Uvri5n7DBvhXeb8W4wde6pvbCZKo-OMUIrn5JaimJOvv8FwPMxm1cYRZLOo3W8vU4rv1DLI5uozg2yuVn8FAAD__6lGF-Q">