You're compiling that code with -fpermissive
set which is downgrading the error to a warning.
-fpermissive
Downgrade some diagnostics about nonconformant code from errors to warnings.
Thus, using -fpermissive will allow some nonconforming code to compile.