Thread: Bjarne's comments about exception specification

  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    1,579

    Bjarne's comments about exception specification

    Hello everyone,


    How do you understand the Bjarne's comments about exception specification? Especially, "not required to be checked across compilation-unit" and "violations will not be caught at run time"?

    section 14.6.1 Checking Exception Specifications

    --------------------
    Importantly, exception-specifications are not required to be checked exactly across compilation-unit boundaries. Naturally, an implementation could check. However, for many large and long-lived systems, it is important that the implementation does not -- or, if it does, than it carefully gives hard errors only where violations will not be caught at run time.
    --------------------


    thanks in advance,
    George

  2. #2
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Well I'm not sure exactly what he means, but I do know that exception specifications are completely useless and should be avoided whenever possible:
    Chapter 75. Avoid exception specifications

  3. #3
    Registered User
    Join Date
    Apr 2006
    Posts
    2,149
    It means that if exception specifications in two different compilation units disagree, that does not have to be a compile time error. It is however, undefined behavior.
    It is too clear and so it is hard to see.
    A dunce once searched for fire with a lighted lantern.
    Had he known what fire was,
    He could have cooked his rice much sooner.

  4. #4
    Registered User
    Join Date
    May 2006
    Posts
    1,579
    Thanks cpjust,


    I need to maintain some code which has exception specification, and I have to understand the concept. Looks like you are experienced at this topic, any ideas about my original question?

    Quote Originally Posted by cpjust View Post
    Well I'm not sure exactly what he means, but I do know that exception specifications are completely useless and should be avoided whenever possible:
    Chapter 75. Avoid exception specifications

    regards,
    George

  5. #5
    Registered User
    Join Date
    May 2006
    Posts
    1,579
    Thanks King,


    What means this part?

    --------------------
    However, for many large and long-lived systems, it is important that the implementation does not -- or, if it does, than it carefully gives hard errors only where violations will not be caught at run time.
    --------------------

    Quote Originally Posted by King Mir View Post
    It means that if exception specifications in two different compilation units disagree, that does not have to be a compile time error. It is however, undefined behavior.

    regards,
    George

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Exception handling in a large project
    By EVOEx in forum C++ Programming
    Replies: 7
    Last Post: 01-25-2009, 07:33 AM
  2. exception handling
    By coletek in forum C++ Programming
    Replies: 2
    Last Post: 01-12-2009, 05:28 PM
  3. about exception specification
    By George2 in forum C++ Programming
    Replies: 1
    Last Post: 01-27-2008, 04:25 AM
  4. Bjarne's exception safe sample
    By George2 in forum C++ Programming
    Replies: 13
    Last Post: 12-28-2007, 05:38 PM
  5. Exception idea in C compatible library. Comments.
    By anonytmouse in forum Windows Programming
    Replies: 2
    Last Post: 10-31-2003, 09:11 AM