This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/25191] exception_defines.h #defines try/catch
- From: "mark at codesourcery dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 24 Sep 2008 13:03:17 -0000
- Subject: [Bug libstdc++/25191] exception_defines.h #defines try/catch
- References: <bug-25191-11686@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #57 from mark at codesourcery dot com 2008-09-24 13:03 -------
Subject: Re: exception_defines.h #defines try/catch
jason at gcc dot gnu dot org wrote:
> ------- Comment #55 from jason at gcc dot gnu dot org 2008-09-23 20:43 -------
> It seems reasonable to me for try { X } catch... to mean X when
> -fno-exceptions. We don't need to error except on throw.
We have to be careful, in some cases. For example:
extern int f();
template <typename T>
struct S {
static int i;
};
template <typename T>
int S<T>::i = f();
int main() {
try {
return 0;
} catch (...) {
return S<int>::i;
}
}
This program, IIRC, is guaranteed to call "f", as a side-effect of the
presence of the catch-clause? Of course, the C++ FE could still process
the "catch" clause; my only point is that we cannot literally just throw
away the catch clause.
I don't objection to -fno-exceptions silently discarding catch clauses,
as long as we avoid the kind of problem above.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25191