In C++ binaries, I find Qt methods like ??4QString@@QEAAAEAV0@AEBV0@@Z
which demangle to
public: class QString & __ptr64 __cdecl QString::operator=(class QString const & __ptr64) __ptr64
or in shorter form, QString& QString::operator=(QString const&)
. The return value does not appear to be used. What is the purpose of this "unary equals", given that it does not seem to be a construct people write in the original code?
Edit
I found the source of my confusion. I'm perfectly award of the calling convention with this
, and what operator=
is supposed to do. It's common, in my experience, for people to indicate this
as a direct argument when reversing software. This is, for instance, what IDA does. It was what I was intending to do as well. So, it would have been considered unary, as I wrote it only take on argument (this
).
It turns out that IDA somehow incorrectly assigned the type, and gave it the signature __int64 __fastcall QString__operator_(_QWORD)
instead of QString* __fastcall QString__operator_(QString *, QString const *)
. I don't know what caused this. The output from [demangler.com], which I put in the first half of my post, did not include the implicit this
, contrary to my expectations.
operator=
, includingvoid
. But the default behavior is to return*this
as a reference. – MSalters Jun 22 '20 at 12:21this
(it's a class member function, not a free function). – HolyBlackCat Jun 22 '20 at 13:33