On Mon, Jan 04, 2021 at 03:44:46PM -0500, Jason Merrill wrote:
> This change is OK, but part of the problem is that we're trying to do
> overload resolution for an S copy/move constructor, which we shouldn't be
> because bit_cast is a prvalue, so in C++17 and up we should use it to
> directly initialize the target without any implied constructor call.
> 
> It seems we're mishandling this because the code in
> build_special_member_call specifically looks for TARGET_EXPR or CONSTRUCTOR,
> and BIT_CAST_EXPR is neither of those.
> 
> Wrapping a BIT_CAST_EXPR of aggregate type in a TARGET_EXPR would address
> this, and any other places that expect a class prvalue to come in the form
> of a TARGET_EXPR.

I can try that tomorrow.  Won't that cause copying through extra temporary
in some cases though, or is that guaranteed to be optimized?

        Jakub

Reply via email to