public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Brian Dessent <brian@dessent.net>
To: Jason Cipriani <jason.cipriani@gmail.com>
Cc: John Love-Jensen <eljay@adobe.com>,
	 	GCC-help <gcc-help@gcc.gnu.org>,
	Ted Byers <r.ted.byers@rogers.com>
Subject: Re: try, finally
Date: Fri, 21 Mar 2008 22:50:00 -0000	[thread overview]
Message-ID: <47E43BA0.FD19877D@dessent.net> (raw)
In-Reply-To: <c09049bf0803201910h3eaeb34fwd5e00dc2a35efd6f@mail.gmail.com>

Jason Cipriani wrote:

> One feature that I have
> always desired the most in a C++ compiler is strict enforcement of
> throw() clauses.

Since you seem to be well aware of the design of C++ exceptions you
should realize why this is a near impossibility.  In order for the
compiler to enforce a throw declaration, it would have to have complete
knowledge of the entire outbound call graph of the function.  Two things
stand in the way of this: separate compilation and function
pointers/virtual functions.  The problem of separate compilation (i.e.
that the compiler only has local knowledge of a given translation unit
at any time) can somewhat be dealt with by using gcc --combine, but
that's more of a crutch.  It won't fix the issue that necessitated
separate compilation in the first place: the explostion of complexity as
the size of one "unit" grows.  (And here I'm not speaking at all of the
human factors of keeping source units small and maintainable, I'm
strictly referring to the algorithmic complexity experienced by the
compiler.)

Longer term, the gcc LTO project will eventually provide a better
infrastructure for whole-program optimizations, but it will still not be
able to see past library boundaries.  That might not be a problem if
like you say C++ had been more Java-like and required accurate throw
declarations from the beginning.  But there is just no reasonable way to
expect that now, so from a compiler standpoint the only way to implement
enforcement of throw declarations would be to "see down into" all
library code (unrealistic for all but perhaps embedded applications) or
to rewrite all library code to include accurate throw declarations in
their headers and then tell the compiler it can trust them.  Either way,
it's a ton of work.

And this hasn't even begun to address the issue of function pointers and
virtual methods, where the call graph can't even be known at compile
time.  I'm sure you could construct a pathological testcase without too
much effort for which it would be provably impossible to enforce throw
declarations at compile or link time.

However, you may be interested in Brendon Costa's EDoc++ which consists
of a hacked up gcc that embeds additional exception and callgraph data
into the objects, and a post processing tool to recover, combine, and
analyze it all at link time.  <http://edoc.sourceforge.net/>

Brian

  parent reply	other threads:[~2008-03-21 22:50 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-19 16:13 Jason Cipriani
2008-03-19 16:14 ` Jason Cipriani
2008-03-19 17:02   ` Tim Prince
2008-03-19 16:37 ` Brian Dessent
2008-03-19 17:31 ` Ted Byers
2008-03-19 17:37 ` me22
2008-03-19 19:09   ` Jason Cipriani
2008-03-19 19:09     ` me22
2008-03-20  5:50       ` Jason Cipriani
2008-03-20 13:30       ` Noel Yap
2008-03-21  2:27         ` Jason Cipriani
2008-03-19 21:04     ` Ted Byers
2008-03-20  6:28       ` Jason Cipriani
2008-03-20 12:24         ` John Love-Jensen
2008-03-21  2:11           ` Jason Cipriani
2008-03-21  2:37             ` me22
2008-03-21  2:45               ` Jason Cipriani
2008-03-21 15:24             ` Noel Yap
2008-03-21 22:50             ` Brian Dessent [this message]
2008-03-21 23:14               ` Noel Yap
2008-03-20 14:50         ` Ted Byers
2008-03-21  2:26           ` Jason Cipriani
2008-03-25 22:28 ` Ian Lance Taylor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=47E43BA0.FD19877D@dessent.net \
    --to=brian@dessent.net \
    --cc=eljay@adobe.com \
    --cc=gcc-help@gcc.gnu.org \
    --cc=jason.cipriani@gmail.com \
    --cc=r.ted.byers@rogers.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).