fixed bugs in GNU compilers and MSVC