<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/144232>144232</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
__builtin_is_replaceable issues
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
jakubjelinek
</td>
</tr>
</table>
<pre>
```c
struct E trivially_relocatable_if_eligible replaceable_if_eligible {
E (E &&);
E &operator= (E &&) = default;
};
static_assert (__builtin_is_replaceable (E), "");
E &&foo ();
void
bar (E &y)
{
E x = foo ();
y = foo ();
}
```
This and also
```c
struct F trivially_relocatable_if_eligible replaceable_if_eligible {
F (F &&) = default;
F &operator= (F &&);
};
struct G replaceable_if_eligible { G (G const &) = default; };
struct I replaceable_if_eligible { I &operator= (const I &) = default; };
static_assert (__builtin_is_replaceable (F), "");
static_assert (__builtin_is_replaceable (G), "");
static_assert (__builtin_is_replaceable (I), "");
```
is where my current GCC implementation disagrees with clang trunk.
Sure, none of the classes here are default-movable, but all are replaceable_if_eligible, so that is irrelevant.
I believe all of them are eligible for replacement though. None of these have any non-static data members nor bases, so the first two bullets of https://eel.is/c++draft/class.prop#6 don't apply, none of these has deleted dtor.
For the first class I've tried to show in bar function that it can be successfully direct initialized from an xvalue of type E and it can be also assigned from an xvalue of type E.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJysVU1v8joT_TXOZlQUHCBkkQX9CGLzbt67R048IW4dO7LH8HB__ZWTllIure4jPVLEh2fmnOM5Y0d4rw4GsWTLR7Z8TkSgzrryVbyF-hW1MviW1FaeS7ZKp6dh6caTCw3BC5BTRyW0Pu8datsIErXGvWr3qNVB1RrB4aBFg_9aZ_kjSzcAL8D4On6sxqdg2ef6yg7oBFnHsuebNIhLElsRNE0lLH9-_xH1CVLNXniPjmLlfl8HpUmZvfL7K0kjamTlT8A4H5_iAvPB11obE69DR6skSze1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