What are some examples of code that are not standards compliant when using visual C++? Something that is allowed to compile under visual C++ but nothing else.
You can find all the Microsoft language extensions here; you may also want to have a look to the areas of the language where VC++ is not compliant to the standard.
One that I thought was standard (I noticed it when I enabled the /Za switch) is the "magic l-value cast":
char *p;
(( int * ) p )++;
Some version of Visual C++ accept to pass non-const reference to temporary object. Something like that :
void DoSomething(std::string& str);
void NonConformantFunction()
{
DoSomething("Temporary std::string created here");
}
"Something that is allowed to compile under visual C++ but nothing else"
and
"code that are not standards compliant"
do not describe exactly the same thing. A compiler may be fully standard compliant while having extensions that are unique to that compiler, while a non-compliance is something explicitly prohibited by the standard. There is also a number of "undefined" or "implementation defined" parts of the ISO standard that might prevent portability without being non-compliant. Moreover many supported extensions are supported by other compilers so are examples of one of your constraints but not the other.
Now that said, the major extension of VC++ that would render its code non-portable are all of the C++/CLI extensions, and therefore also the .NET Framework class library which requires them.
There is an official page on microsoft.com saying what are the parts where VC++ is not compatible with the standard. However a different issue is where it is compatible by default with the standard. For example the default scope for for
variables is still wrong in VC++2010.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With