#define TYPE_CHECK(T, S) \\
while (false) { \\
*(static_cast
Yes, but the compiler still performs syntax & semantic checks on the loop contents. So if something is wrong (i.e. the implicit type conversion from S*
to T*
is illegal, which happens if T
is neither S
nor a base class of S
), compilation fails. Otherwise, the quality of the resulting machine code is not affected since the optimizer will detect the nonreachable code and remove it silently.