public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c++/4898: adding an option to verify exception specifications
@ 2001-11-13  9:36 Luc.Maisonobe
  0 siblings, 0 replies; 2+ messages in thread
From: Luc.Maisonobe @ 2001-11-13  9:36 UTC (permalink / raw)
  To: gcc-gnats


>Number:         4898
>Category:       c++
>Synopsis:       adding an option to verify exception specifications
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    unassigned
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Mon Nov 19 03:26:00 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     Luc Maisonobe
>Release:        gcc-3.0
>Organization:
>Environment:
All
>Description:
C++ allows to specify exceptions in the function declaration
but do not enforces it. When lots of classes and methods are
involved, maintaining up-to-date specifications is very
difficult, and every missed exception create runtime
problems (unexpected exception -> abort -> core dumped). For
the moment the lack of support tools prevents developers
from using these specifications effectively.

It would be very helpful to have a switch on the compiler
to get warnings if a function do not declare the exceptions
that can be thrown by itself and its callee and that are
either not caught or that are rethrown. This could be an
extension to the existing -Weffc++ flag.

As an example, one can look at Java that enforces the proper
declarations, this is nice.
>How-To-Repeat:

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="MissingThrowSpec.cc"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="MissingThrowSpec.cc"

Y2xhc3MgQSB7CiAgaW50IGlfOwpwdWJsaWM6CiAgQSAoaW50IGkpIDogaV8gKGkpIHt9CiAgQSAo
Y29uc3QgQSYgYSkgOiBpXyAoYS5pXykge30KICBpbnQgZ2V0SSAoKSBjb25zdCB7IHJldHVybiBp
XzsgfQp9OwoKY2xhc3MgQiB7CiAgaW50IGlfOwpwdWJsaWM6CiAgQiAoaW50IGkpIDogaV8gKGkp
IHt9CiAgQiAoY29uc3QgQiYgYikgOiBpXyAoYi5pXykge30KICBpbnQgZ2V0SSAoKSBjb25zdCB7
IHJldHVybiBpXzsgfQp9OwoKdm9pZCBnICgpCiAgdGhyb3cgKEIpCnsKICB0aHJvdyBCICgyKTsK
fQoKdm9pZCBmICgpCiAgdGhyb3cgKEEpIC8vIDwtLSB0aGlzIHNob3VsZCBiZSB0aHJvdyAoQSxC
KQogICAgICAgICAgICAvLyBpdCB3b3VsZCBiZSBuaWNlIGlmIHRoZSBjb21waWxlcgogICAgICAg
ICAgICAvLyBjb3VsZCB3YXJuIGFib3V0IHRoZSBtaXNzaW5nIEIgd2hlbgogICAgICAgICAgICAv
LyBhc2tlZCBieSBhIHNwZWNpZmljIGNvbXBpbGF0aW9uIGZsYWcKewoKICAvLyBnICgpIHdpbGwg
dGhyb3cgYSBCIHRoYXQgaXMgbm90IGRlY2xhcmVkLAogIC8vIHNvIHRoZXJlIHdpbGwgYmUgYW4g
dW5leHBlY3RlZCBleGNlcHRpb24KICAvLyBhbmQgYW4gYWJvcnQKICBnICgpOwogIHRocm93IEEg
KDEpOwp9CgppbnQgbWFpbiAoaW50LCBjaGFyKiopCnsKICB0cnkgeyBmICgpOyB9CgogIGNhdGNo
IChBIGEpIHsgcmV0dXJuIGEuZ2V0SSAoKTsgfQoKICAvLyB0aGUgZm9sbG93aW5nIGNhdGNoIGNs
YXVzZSBpcyB1c2VsZXNzLAogIC8vIHRoZSBleGNlcHRpb24gd2lsbCBiZSBjb25zaWRlcmVkIHVu
ZXhwZWN0ZWQKICAvLyB3aGlsZSB1bndpbmRpbmcgdGhlIHN0YWNrIGF0IGYgKCkgbGV2ZWwKICBj
YXRjaCAoQiBiKSB7IHJldHVybiBiLmdldEkgKCk7IH0KCiAgcmV0dXJuIDA7Cgp9Cg==


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: c++/4898: adding an option to verify exception specifications
@ 2002-09-15 12:37 nathan
  0 siblings, 0 replies; 2+ messages in thread
From: nathan @ 2002-09-15 12:37 UTC (permalink / raw)
  To: Luc.Maisonobe, gcc-bugs, gcc-prs, nobody

Synopsis: adding an option to verify exception specifications

State-Changed-From-To: open->analyzed
State-Changed-By: nathan
State-Changed-When: Sun Sep 15 12:37:57 2002
State-Changed-Why:
    yes it would be nice. Note, that C++ is not as strict
    as Java. For instance
    void Foo (int i) throw () {
       if (i) throw i;
    }
    
    is well-formed provided i is never non-zero. And besides
    even then it's not an error, because std::terminate
    gets called (though the programmer probably would
    like to be told)

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=4898


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-09-15 19:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-11-13  9:36 c++/4898: adding an option to verify exception specifications Luc.Maisonobe
2002-09-15 12:37 nathan

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).