https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112908
Bug ID: 112908
Summary: __reference_{converts,constructs}_from_temporary
checks for move constructor when binding prvalue to
reference of the same type
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: mital at mitalashok dot co.uk
Target Milestone: ---
The following compiles on trunk:
struct NonMovable {
NonMovable() = default;
NonMovable(NonMovable&&) = delete;
};
static_assert( __reference_converts_from_temporary(int&&, int));
static_assert(!__reference_converts_from_temporary(NonMovable&&,
NonMovable));
static_assert( __reference_constructs_from_temporary(int&&, int));
static_assert(!__reference_constructs_from_temporary(NonMovable&&,
NonMovable));
When the NonMovable assertions should fail because there *is* a temporary being
bound to a reference (in exactly the same way as the int case).
We can observe it instantiating constructors that shouldn't be too:
template<typename T>
struct S {
template<typename U = T>
S(const S&&) noexcept(U()) {}
};
static_assert(__reference_converts_from_temporary(const S<bool>&&, const
S<bool>));
static_assert(__reference_converts_from_temporary(const S<void*>&&, const
S<void*>));
Which complains about a conversion from void* to bool even though constructors
shouldn't be looked at.