c++: fix ICE with -Wduplicated-cond [PR107593]