an****************@gmail.com wrote:
Victor Bazarov wrote:
Needs to be
s.template member<Type>();
to be standard C++. MS compiler hasn't got there yet.
I haven't yet written (or maintained) template heavy C++ code.
So, this is new for me (obvious, if you had a look at my
previous post, which the OP was kind enough to call nifty.)
My question is if the original code was incorrect, and MS
compiler compiled it successfully, what does it mean?
It's called a "language extension". See more musings below.
Will
the MS compiler generate wrong object code for correct
(standard compliant) C++ code, in some very rare cases?
(Probably template heavy stuff.)
Any thoughts on that?
Well, we cannot say anything about the correctness of the generated code,
since it's generated from a non-standard extension. However, the VC++ is
known to also accept the standard code , and all we can do about the
situation is to compare the codes generated from either C++ program (with
and without the 'template' keyword) and conclude that the non-standard
source yields the same machine code, for example.
The behaviour of the two resulting programs (from the non-standard source
and the amended one) can also be compared. Whether it has any bearing on
the results of compiling _similar_ programs, I don't know. Maybe. You
should also ask in microsoft.public.vc.language newsgroup, it's full of
very knowledgeable folk, especially when it comes to VC++.
VC++ has got much better over the past couple of years (I consider v7.1
the first really worth using if you want to learn standard C++, v8 is even
better). But it still has some quirks, especially when it comes to being
able to compile non-standard code without even a warning. AFAIK, VC++
team is not going to do much about those "bugs" in their compiler simply
because VC++ successfully compiles the well-formed code. Issuing warnings
or other diagnostics about ill-formed programs is often up to the
implementors. The compiler is free to keep compiling ill-formed code and
generate what it considers to be the best approximation of what the
programmer wanted the code to do. It's non-portable, yes, but it's fully
within the language specifications.
V