to force gcc to emit additional warnings about unhandled exceptions

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • adaslaw@gmail.com

    to force gcc to emit additional warnings about unhandled exceptions

    Hi

    Is it possible to force gcc (or xlc) compiler to emit compilation
    warning or compilation error for such code:

    void fooA() throw (MyException)
    {
    ...
    throw MyException();
    ...
    }

    void fooB() throw()
    {
    fooB();
    }

    I would like to be warned that in function fooB:
    * there is no appropriate catch block to catch MyException from fooA
    .... or ...
    * fooB should be declared as: void fooB() throw(MyExcepti on)

    Any idea to force the compiler to emit such warnings?

    Kind regards,
    Adam
  • Victor Bazarov

    #2
    Re: to force gcc to emit additional warnings about unhandled exceptions

    adaslaw@gmail.c om wrote:
    Is it possible to force gcc (or xlc) compiler to emit compilation
    warning or compilation error for such code:
    [..]
    This is a compiler-specific question and should be asked in the
    newsgroup dedicated to that compiler. Tool invokation is not
    on topic here. This is a language newsgroup.

    V
    --
    Please remove capital 'A's when replying by e-mail
    I do not respond to top-posted replies, please don't ask


    Comment

    • Jerry Coffin

      #3
      Re: unhandled exceptions and exception specs

      In article <f38e370c-1f1c-44d6-85ed-
      9bd87d765e2d@d4 5g2000hsc.googl egroups.com>, james.kanze@gma il.com
      says...

      [ ... ]
      No. "throw()" guarantees absolutely that the function will
      never exit via an exception. §15.4/8,9:
      I'm not sure what I was thinking when I said otherwise, but you're
      obviously correct.

      --
      Later,
      Jerry.

      The universe is a figment of its own imagination.

      Comment

      • James Kanze

        #4
        Re: unhandled exceptions and exception specs

        On 15 mar, 19:22, Jerry Coffin <jcof...@taeus. comwrote:
        In article <f38e370c-1f1c-44d6-85ed-
        9bd87d765...@d4 5g2000hsc.googl egroups.com>, james.ka...@gma il.com
        says...
        [ ... ]
        No. "throw()" guarantees absolutely that the function will
        never exit via an exception. §15.4/8,9:
        I'm not sure what I was thinking when I said otherwise, but you're
        obviously correct.
        An earlier draft of the standard? I too seem to recall having
        seen something similar---that regardless of the exception
        specification, std::bad_except ion could propagate. I wasn't the
        only one, however, who found it totally unacceptable, and it
        didn't make it into the final version of the standard.

        --
        James Kanze (GABI Software) email:james.kan ze@gmail.com
        Conseils en informatique orientée objet/
        Beratung in objektorientier ter Datenverarbeitu ng
        9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

        Comment

        Working...