<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/66552>66552</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Clang fails to implement CWG2352, temporary pointer created during reference binding
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Eisenwave
</td>
</tr>
</table>
<pre>
See https://godbolt.org/z/8W699x6q6.
```cpp
int* p;
const int*&& r = static_cast<int*&&>(p);
```
This code should be ill-formed because `const int*` is not reference-compatible with `int*`. This is due to the fact that there is no conversion from `int**` to `const int**`. GCC rejects it, clang doesn't.
Prior to [CWG2352](https://cplusplus.github.io/CWG/issues/2352.html), this would result in temporary materialization and the reference binding to a temporary `int*`, which can actually be converted to an `int**`. After CWG2352, this should be ill-formed.
### See Also
- [Can you bind a const T*&& to an xvalue of type T*?](https://stackoverflow.com/questions/77115150/can-you-bind-a-const-t-to-an-xvalue-of-type-t) (related discussion on Stack Overflow)
- [[dcl.init.ref] p4](https://eel.is/c++draft/dcl.init.ref#4) (relevant wording)
- [[CWG2018]](https://cplusplus.github.io/CWG/issues/2018.html) (related issue)
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycVM2OozoTfRqzKYHA_HRYsMjP0Mvvk2akXl4ZUwTfa2zGLpLJPP2VoTudnu7VlQgRtqvOqVOnLLxXZ4PYsPLAylMkFhqta74pj-YqLhh1tr813xFhJJo9y_eMt4y3Z9t3VlNi3Znx9jfj7e6lqutf1c8qYemJpXtWpdsj53lbUYYY38PM8sO2IK3xBNsy4xXjFThg-Qk8CVLyLyk8sfz4eIDl3xjfzYzX9yx3oO3zx6g8SNsj-NEuuocOQWkdD9ZNGL6kWDxCIPYIX6WgPBhL4HBAh0ZiLO00C1KdRrgqGkPM_XQCK5Dy0C8IZIFGhEFIAhpFeKHDLSNIay7ovLIGBmenhzQbLtlPbF4h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