You're not using the compiler you have installed in MSYS2, but some other compiler you installed before. Add more information, how you're running it, how do you know its version, etc. Also please always tag
c++
in addition to a specific c++-??
version.