This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/79249] Lambda call does not create exception handler.
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 26 Jan 2017 20:48:37 +0000
- Subject: [Bug c++/79249] Lambda call does not create exception handler.
- Auto-submitted: auto-generated
- References: <bug-79249-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79249
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Slightly further reduced:
template <typename FnT>
auto attempt(FnT f)
{
return [f]()
{
try
{
f();
}
catch(...)
{
__builtin_puts("caught");
}
};
}
// More complex behavior does not seem to matter here, however
// removing "noexcept" results in GCC generating a program that works as
// expected:
void f_ident() noexcept { }
// Even though this is not actually referenced by the other code, removing
// it causes GCC to generate a program that works as expected.
void test_attempt_call_with_exception_handler()
{
attempt(f_ident)();
}
void g()
{
throw 1;
}
int main()
{
attempt(g)();
}