<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/78355>78355</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[Clang] `E[...]`/`E(...)` does not evaluate `E` if it calls a `static` overload
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
MitalAshok
</td>
</tr>
</table>
<pre>
Example:
```c++
struct X {
X(int x) {
__builtin_printf("X(%d)\n", x);
}
static void operator()() {
__builtin_printf("operator()\n");
}
static void operator[]() {
__builtin_printf("operator[]\n");
}
static void f(int) {
__builtin_printf("f\n");
}
};
int main() {
X(__builtin_printf("main()1\n"))();
X(__builtin_printf("main() 2\n"))[];
X(__builtin_printf("main() 3\n")).f(0);
}
```
Prints:
```
operator()
operator[]
main() 3
X(10)
f
```
Instead of the expected:
```
main()1
X(8)
operator()
main() 2
X(9)
operator[]
main() 3
X(10)
f
```
https://godbolt.org/z/sv14fjMYK
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0VEFvozwU_DWPi1VkHjjAgUPbFOnTp0p77J4qg03iroMjbKLu_vqVTZNCms22h42QUcZ-M_PGxtxatemlrIDdAVtHfHRbM1SPynF9a7fmR9QY8bN6eOW7vZaQ3gJdAz2OKzo9LeCdfwJq3TC2jjwRyN8QQgh5AixU78grYLmc8b_n52ZU2qn-eT-o3nWABSA-hRcTgCWw-x4QAe8DA6RHAsjXc0uezDruVEsORgli9nLgzgyBqZzGmfxl3bOio_RMlZBPC4dcPwhf7fus9oL-X8S7KewvSHbXVfL1CZ1Gv5U7rvoPjfk9uyzxvjyZiR03ZZHtZ0gILlmmrL7Mki5YYr-Azu28Z3A87PMYvnlS-6fPYvp7dpqW2OQ6YAtTAfENJPRU1F0x8l9vneSCmI64rSTydS9bJ8V1Z_MdOQleMDkzvsj_VFP-u8a2zu1DwFgD1hsjGqNdbIYNYP0LsLaHJOteHr__Py2PRJWKMi15JKskpyzLEEsWbSvZ0RXNkqJLuqwsRUqx5LJoUpp3RZoJEakKKWY0SVaYsCJhcdFiliRN3jZJQXNWQkbljisda33YeQeRsnaUVV6kjEWaN1LbcI0itpr3G3-o2DoaKr_-phk3FjKqlXX2ncEpp8Pdex8q2JrAij4Au4vj2Oe3or5vD2HhISxhRYkw0pLeOCIPXI_cyalqRYnqiHKk5Vpbwj063Qp-yhzkoA0X0Tjo6ixV5bZjE7dmB1h7b2-vm_1gXmTrAOvQqgWsQ7e_AwAA__97bKYv">