CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2005
    Posts
    445

    [RESOLVED] why do I need exceptions specifications

    Hi all,

    Are there any benefits for using exceptions specifications ?

  2. #2
    Join Date
    Jul 2002
    Location
    Portsmouth. United Kingdom
    Posts
    2,727

    Re: why do I need exceptions specifications

    Some words from Herb Sutter about it.

    http://www.gotw.ca/publications/mill22.htm

    • Moral #1: Never write an exception specification.
    • Moral #2: Except possibly an empty one, but if I were you I’d avoid even that.
    "It doesn't matter how beautiful your theory is, it doesn't matter how smart you are. If it doesn't agree with experiment, it's wrong."
    Richard P. Feynman

  3. #3
    Join Date
    Nov 2008
    Location
    England
    Posts
    748

    Re: why do I need exceptions specifications

    None whatsoever, in fact quite the opposite.

    Violation of an exception specification causes std::terminate to be called which immediately calls std::abort exiting your program without any cleanup whatsoever, possibly leaving files for instance in a complete state of disrepair.

    You are probably best off forgetting they even exist.
    Get Microsoft Visual C++ Express here or CodeBlocks here.
    Get STLFilt here to radically improve error messages when using the STL.
    Get these two can't live without C++ libraries, BOOST here and Loki here.
    Check your code with the Comeau Compiler and FlexeLint for standards compliance and some subtle errors.
    Always use [code] code tags [/code] to make code legible and preserve indentation.
    Do not ask for help writing destructive software such as viruses, gamehacks, keyloggers and the suchlike.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured