What is the function of “(void) (&_min1 == &_min2)” in the min macro in kernel.h?

The statement

(void) (&_min1 == &_min2);

is a guaranteed “no-op”. So the only reason it’s there is for its side effects.

But the statement has no side effects!

However: it forces the compiler to issue a diagnostic when the types of x and y are not compatible.
Note that testing with _min1 == _min2 would implicitly convert one of the values to the other type.

So, that is what it does. It validates, at compile time, that the types of x and y are compatible.

Leave a Comment