add better working-g++ check (patch from #2017)