Detect g++-x.y variants for test compilation.