c++: Fix ICE with -Wmismatched-tags [PR105725]