Why doesn't all the compilers follow Standard C++?

Hi, I am new to C++.
I want to ask a question. I have seen many times that different compilers follow different rules. LIke in GNUC++ compiler we can set array length (one that you type in between [] )as a variable and on the other hand we can't do this is VC++2010 Compiler.
Why this happens? This thing confuses me a lot. How am I supposed to know that which Code strictly follows Standard C++ and which doesn't.
Please help me. and also recommend me a strict compiler and IDE that strictly follows Standard C++.
Thanks,
-Himansh
> Why this happens?

The reason why this happens is political rather than technical.

With the GNU or clang compilers, disable Linuxisms with the options -std=c++11 -pedantic-errors

With the Microsoft compiler, disable Microsoftisms with the option /Za
man wrote:
Some users try to use -Wpedantic to check programs for strict ISO C conformance. They soon find that it does not do quite what they want: it finds some non-ISO practices, but not all---only those for which ISO C requires a diagnostic, and some others for which diagnostics have been added.

As long as a compiler issues a diagnostic where the standard requires it to do so, it is a conforming implementation.

There is no way for a compiler to guarantee that a program is well-formed; for instance all violations of ODR can't be caught while compiling one translation unit. So, 'no diagnostic is required' (falls under 'undefined behaviour').

But:
Many erroneous program constructs do not engender undefined behavior; they are required to be diagnosed. - IS
Why this happens? This thing confuses me a lot.

To give a slightly more general perspective, that's how free languages evolve: any vendor can change it in any way they feel like, or copy (and tweak) a popular change introduced by another vendor. When (if) the change is standardized, every vendor is expected (but isn't under any obligation) to copy it and make it work exactly as described in the standard document. Then they make more changes, and the cycle moves on.

How am I supposed to know that which Code strictly follows Standard C++ and which doesn't.

In general, it can only be achieved by carefully inspecting the code and comparing it against the standard document (of some chosen revision). For many practical purposes, compiling with several different compilers with strict conformance options goes a long way. As already pointed out, diagnostics are not always required or even possible.
hmm, I see.
Thank you all for your kind support.
Topic archived. No new replies allowed.