Re: Unhandled exception - How to turn off!



Vladimir Nesterovsky wrote:

bad_cast,
bad_exception,
bad_typeid,
terminate,
type_info,
uncaught_exception,
unexpected

all these functions and classes are deeply language bounded, and reside in the std namespace.

Yes, in some cases the compiler implicitly calls std library functions, such as uncaught_exception or unexpected. The compiler has every right to generate implicit function calls. Those two functions, however, are the dark side of C++, and the general consensus is that it's better to avoid them. I wouldn't touch uncaught_exception or exception specifiers with a 10-foot pole:

http://www.gotw.ca/gotw/047.htm
http://www.gotw.ca/gotw/082.htm

Sometimes it is necessary for the compiler to implicitly call a function, when a feature can't be implemented in any other way. For example, dynamic_cast operating on reference types has no other choice but to throw std::bad_cast on error. However, bad_cast is still a std library feature, implemented as an external .lib. It's just that the compiler is allowed to implicitly generate certain calls to the std library.

There are certainly some functions that enjoy special treatment, such as main. But this is being kept to an absolute minimum. For example, it is wise that a string literal is a character array, and not an std::string.

The only time the compiler forces a special memory layout on you is with type_info, in which case it's inevitable. Many people argue that the current type_info feature is not extensive enough, and to fully implement reflection, the compiler would have to build some user accessible data types, there's no way around it. I don't think it would violate the main design philosophy of the language.

Tom
.



Relevant Pages

  • Re: Ada exception block does NOT work?
    ... The parameter/formal declarations are like ... the compiler would guess for you how to call puts. ... > * implicit declaration of external functions. ... > K&R probably where good assember programmers but they where lousy compiler ...
    (comp.lang.ada)
  • Re: trim(string) problems
    ... >> Together these make me think it is a compiler problem ... >> but correctly finds size with both explicit and implicit ... that makes my test program with the module work and should ...
    (comp.lang.fortran)
  • Re: first time using direct access files: recl ??
    ... I suppose the compiler *MIGHT* be omitting non-written trailing ... he was particularly metioning source form issues. ... implicit typing (evil), the compiler will just make one up anyway. ...
    (comp.lang.fortran)
  • operators for matrix
    ... Using the ifort 9.1 compiler give error: ... interface operator ... module procedure MatrixMultiplication ... implicit none ...
    (comp.lang.fortran)
  • Re: C# 3.0 Proposals
    ... Implicit means that it is assumed what the type is, ... Whereas with var, you can't do it, you will get a compiler error. ... "26.1 Implicitly typed local variables ...
    (microsoft.public.dotnet.languages.csharp)