MSVC6 not up to Standard?

Started by
23 comments, last by DanG 22 years, 4 months ago
I have been noticing that my version of MSVC 6 is not fallowing the ANSI/ISO C++ Standard to the T like it should. For example this code should not compile int main(int argc, char * argv[]) { for (int i = 0; i < 10; i++) // i should be scoped to the loop ; cout << i << endl; // this should be illigal, i undefined } why wouldn''t MS bring their compiler up to standard on things like this? Is there some patch i am missing? RELIGION IS THE ROOT OF ALL EVIL
Ambassador: Mr. Bush are you stoned or just really, REALLY dumb?Pres. Bush - I assure you I am not stoned.
Advertisement
1. Backwards compatibility.
2. IIRC, that is what the standard originally specified. Remember, MSVC is getting old, and standards are still changing.

You can get around this by doing something like
  #define for if(0) else for  
ReactOS - an Open-source operating system compatible with Windows NT apps and drivers
Well no, MSVC++ is not up to standard.
There is no patch fixing that.
Imagine how much code that would break.
Including Microsoft''s own.
Welcome into M$-World.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
Are u sure it''s ANSI rules, which define the
loop variable local to the loop?
I''ve heard that some compiler''s do it this way,
but if I switch the old borland c++ 3.1 to ANSI mode,
the loop variable IS defined after the loop.
ANSI C99 Draft, Page 135, Section 6.8.5.3:
The statement
for( clause-1 ; expression-2 ; expression-3 ) statement
behaves as follows: ... If clause-1 is an expression, it is evaluated as a void expression before the final evaluation of the controlling expression.124)

...

124) ... If clause-1 is a declaration, then the scope of any variable it declares is the remainder of the declaration and the entire loop, including the other two expressions.

[Resist Windows XP''s Invasive Production Activation Technology!]
The point is that there is no compiler that is standards-compliant to the T. Furthermore, Microsoft''s position is to be less concerned with standards-compliance and more concerned with backwards compatibility and code compilation. So long as all major libraries can be ported to MSVC with minimal changes, they''re happy (from an interview with MSVC architect on Code Project).
i is in scope using msvc6 because if you declare a variable as arg1 ( for (arg1; arg2; arg3) ) in a for loop, it becomes part of the scope outside of the for loop.

Code comment of the week:
bool hack = false; // DO NOT CHANGE THIS EVER
- Kevin "BaShildy" KingGame Programmer: DigiPenwww.mpogd.com
Enforcing the scope of the loop variable is still not default in VC++ 7.0, but at least now theres a compiler switch for it.

Psalm 137:9: "Happy shall he be, that taketh and dasheth thy little ones against the stones."
--AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.[Project site] [IRC channel] [Blog]
Standard noncompliance issues with MSVC 6.0:
http://support.microsoft.com/support/kb/articles/Q243/4/51.ASP

From what I understand, these have all been fixed (or allowed a compiler switch) in MSVC 7.0.
quote:Original post by Stoffel
From what I understand, these have all been fixed (or allowed a compiler switch) in MSVC 7.0.


Are you sure about that? I was under the distinct impression that partial ordering, partial specialization, and template template parameters are still missing. If they are supported, I'll seriously consider switching back to Microsofts compiler. I doubt it, though.

Edited by - spock on November 26, 2001 6:58:43 AM

This topic is closed to new replies.

Advertisement