 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Dave Theese Guest
|
Posted: Mon Aug 18, 2003 10:33 am Post subject: Re: vc71 conformity to standard |
|
|
Some minutia I just came across while playing around:
1.
It appears that a namespace can be extended using a namespace alias.
According to the standard, this can be done only with an original
namespace
name.
2.
It appears that in the "catch" of a function try block for a
constructor,
you can access base/contained class members that should be
inaccessible.
Note: Proper "for" scoping is now supported, but it's off by default
(at
least in console apps). You have to manually turn it on in the project
properties...
| Quote: | Can anyone, tell me where I should be careful? What standard features are
lacking or are not standard?
|
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
Rob Williscroft Guest
|
Posted: Mon Aug 18, 2003 10:56 am Post subject: Re: vc71 conformity to standard |
|
|
Carl Daniel wrote in news:ewL%a.1654$NQ5.268 (AT) newssvr25 (DOT) news.prodigy.com:
| Quote: | Petre Iantu wrote:
It seems to me that vc71 (vs.net 2003) implemented the standard C++,
quite strictly.
Can anyone, tell me where I should be careful? What standard features
are lacking or are not standard?
- Two-phase lookup of dependent names in template definitions.
|
/Za disable extensions (implies /Op)
/Ze enable extensions (default)
Note one of Microsoft's extension's is to disable Two-phase lookup
of dependent names.
Unfortunately the above switch (/Za) also disables anonymous
struct's, another Microsoft extension, which are unfortunately
used in many windows headers, This is really annoying as I don't
want the compiler to check code that comes with my compiler, I
want it to check mine .
| Quote: | - Support for 'export'.
- Support for calling unexpected() when an exception specification is
violated.
|
I had understood that VC7.1 completly ignored exception
specification 's, but I tried:
#include <iostream>
#include <ostream>
int normal()
{
throw 2;
return 1;
}
int nothrow() throw()
{
normal();
return 0;
}
int main()
{
//int (*nt)() throw() = normal;
int (*nt)() throw() = nothrow;
try
{
std::cout << "Normal: " << nt() << std::endl;
}
catch ( int a )
{
std::cout << "Exception: " << a << std::endl;
}
}
As writen above VC7.1 prints "Exception: 2" and gcc 3.2 prints
"abnormal program termination", presumably via a call to
std::unexpected().
However if I change main to:
int main()
{
int (*nt)() throw() = normal;
//int (*nt)() throw() = nothrow;
... as above ...
}
VC7.1 gives an compilation error:
test.cpp(19) : error C2440: 'initializing' : cannot convert from
'int (*)(void)' to 'int (*)(void) throw()'
None of the functions with this name in scope match
the target type
gcc compiles and gives "Exception 2" as its output.
| Quote: | Thie compiler is fragile (i.e. it's easy to get an ICE) with respect
to some permutations of templates and friends.
|
At first I thought ICE = "Integral Const Expression", but I
guess you mean "Internal Compiler Error" .
Rob.
--
http://www.victim-prime.dsl.pipex.com/
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
David Abrahams Guest
|
Posted: Mon Aug 18, 2003 11:50 pm Post subject: Re: vc71 conformity to standard |
|
|
Rob Williscroft <rtw (AT) freenet (DOT) REMOVE.co.uk> writes:
| Quote: | - Two-phase lookup of dependent names in template definitions.
/Za disable extensions (implies /Op)
/Ze enable extensions (default)
Note one of Microsoft's extension's is to disable Two-phase lookup
of dependent names.
|
But you can't disable that extension yet ;-)
--
Dave Abrahams
Boost Consulting
www.boost-consulting.com
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
Shannon Barber Guest
|
Posted: Tue Aug 19, 2003 12:14 am Post subject: Re: vc71 conformity to standard |
|
|
Rob Williscroft <rtw (AT) freenet (DOT) REMOVE.co.uk> wrote:
[snip]
| Quote: |
I had understood that VC7.1 completly ignored exception
specification 's, but I tried:
[snip] |
It ignores all exception specifications except the one that matters
most, no throw. I think MSVC may have had this behavior since v4.2, 6
definitely does, and I'm pretty sure I remember 5 doing this as well.
One of the Dinkumware guys ought to know for certain ;)
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
David Abrahams Guest
|
Posted: Tue Aug 19, 2003 10:27 am Post subject: Re: vc71 conformity to standard |
|
|
[email]shannon.barber (AT) myrealbox (DOT) com[/email] (Shannon Barber) writes:
| Quote: | Rob Williscroft <rtw (AT) freenet (DOT) REMOVE.co.uk> wrote:
[snip]
I had understood that VC7.1 completly ignored exception
specification 's, but I tried:
[snip]
It ignores all exception specifications except the one that matters
most, no throw.
|
Yes, but it doesn't account for that exception specification _in the
way that the standard mandates_. An exception *can* leave a function
with an empty throw specification without invoking unexpected() under
msvc.
--
Dave Abrahams
Boost Consulting
www.boost-consulting.com
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
Craig Powers Guest
|
Posted: Sat Aug 23, 2003 8:13 am Post subject: Re: vc71 conformity to standard |
|
|
Shannon Barber wrote:
| Quote: |
Rob Williscroft <rtw (AT) freenet (DOT) REMOVE.co.uk> wrote:
[snip]
I had understood that VC7.1 completly ignored exception
specification 's, but I tried:
[snip]
It ignores all exception specifications except the one that matters
most, no throw. I think MSVC may have had this behavior since v4.2, 6
definitely does, and I'm pretty sure I remember 5 doing this as well.
One of the Dinkumware guys ought to know for certain
|
VC6 doesn't ignore throw(), but it certainly doesn't do what it's
supposed to do. Rather than setting things up to call unexpected() if
an exception is thrown, it takes the no throw specification as a
signal that there will be no exceptions and it may optimize away
exception handling for that function (and I believe that is very
hazardous in the event that an exception is actually thrown).
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|