Reputation: 300399
Visual Studio 2010 features a number of extensions (activated by default) / discrepancies with regard to the C++ Standard.
Such discrepancies can be surprising, and elicit a different behavior than other behavior. VS is notably famous for being extremely lax in template code validation, and template code that was accepted and compiled by VS will often be rejected outright by more compliant compilers (CLang, Comeau, icc, gcc, ... to name a few).
The goal of this question is to provide a reference (thus the FAQ tag) for these discrepancies.
Please provide one answer per discrepancy (check for duplicate) and for each:
Note: C++0x is the next standard, so avoid listing C++0x extensions, since they'll be standard soon
From @Matteo Italia: Visual Studio Compliance Page
Upvotes: 3
Views: 390
Reputation: 320777
I use a blog as a notebook for non-complicance issues I find in VS2005. I don't see a point in reposting the whole thing here
http://atarasevich.blogspot.com/2008/02/microsoft-vs2005-c-non-compliance.html
http://atarasevich.blogspot.com/2008/02/microsoft-vs2005-c-non-compliance_07.html
http://atarasevich.blogspot.com/2008/02/microsoft-vs2005-c-non-compliance_08.html
Upvotes: 0
Reputation: 300399
Discrepancy: Visual Studio does not bind non-dependent names in templates during first evaluation.
The Standard requires two-phases evaluation:
Disable ? It is not subject to any option or switch, it is simply not implemented.
Consequences:
Visual Studio only does the second phase, which affects:
template
or typename
keywords are not detected by VSUpvotes: 0
Reputation: 355347
Visual C++ does not fully support value initialization (or rather, there are bugs in all current versions of Visual C++, from Visual C++ 2005 through Visual C++ 2010 SP1).
There are several reported bugs about this (see also this answer to another question).
Consequence: some forms of code that should value initialize an object leave the object or some part of the object uninitialized.
Workaround: do not rely on value initialization.
Upvotes: 1
Reputation: 92381
By default the compiler allows binding a temporary to a non-const reference.
Remedy: use warning level 4
Upvotes: 4
Reputation: 126957
First of all, I'd link Microsoft's take on this topic.
All the Microsoft language extensions can be found here; there's also a page where the areas of the language where VC++ is not compliant to the standard are listed.
Upvotes: 6