I’ve been using clazy for a lot and this is a very very nice tool.
Nevertheless, there is a test for virtual signal and this case seems to be valid.
Why so? isn’t Qt will do some kind of
== for a member function to get a signal address and if it’s a virtual function it’s undefined behavior? Why is the approach kept in clazy?
The commit message linked on that page lays it out more clearly, it does look like that’s the case:
The reason has to do with how MSVC implements pointers to virtual
function members: they are “regular” function pointers to a DLL-local
stub that implements the virtual call. For that reason, a connect()
happening in client code would generate a pointer for the signal that
doesn’t compare equal to the same pointer generated from inside KDDW;
and moc-generated code relies on this comparison to find the index of
I am confused, so this test of clazy seems to be invalid so due to the same cause… isn’t it?
Why just not forbid signals in the virtual hierarchy?
You’re right, the test is intentionally meant to trip up Clazy. As to why virtual signals are not forbidden, your guess is as good as mine
To sum up: we have mentioned that virtual signal is not how it suppose to work, there is a separate check that literally says it, but at the same time there is a workaround to shut up clazy when it sees such thing Ok ok, that really makes sense