Bug 47263 - [C++0x] lambda + dynamic-exception-specification std::unexpected() is not called.
Summary: [C++0x] lambda + dynamic-exception-specification std::unexpected() is not cal...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.5.2
: P3 normal
Target Milestone: 4.6.1
Assignee: Jason Merrill
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-12 03:20 UTC by Kohei Takahashi
Modified: 2011-05-25 01:26 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2011-05-22 20:32:26


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kohei Takahashi 2011-01-12 03:20:28 UTC
In GCC4.5/4.6, if lambda throws unexpected exception, std::unexpected() is not called but std::terminate() is called immidiately.

test code:
#include <exception>
#include <cstdio>
#include <cstdlib>
using namespace std;

int main( void )
{
    set_unexpected( []{ puts( "unexpected" ); fflush( stdout ); throw 0; } );
    set_terminate( []{ puts( "terminate" ); fflush( stdout ); abort(); } );
    try
    {
        []() throw( int ) { throw exception(); }();
    }
    catch( int )
    {
        puts( "catch" );
    }
}

output:
$ ./a.out
terminate
zsh: abort      ./a.out
Comment 1 Jason Merrill 2011-05-23 15:48:49 UTC
Author: jason
Date: Mon May 23 15:48:37 2011
New Revision: 174076

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=174076
Log:
	PR c++/47263
	* decl.c (use_eh_spec_block): Do use an EH spec block for a
	lambda op().

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-eh2.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/decl.c
    trunk/gcc/testsuite/ChangeLog
Comment 2 Jason Merrill 2011-05-25 01:08:34 UTC
Author: jason
Date: Wed May 25 01:08:31 2011
New Revision: 174161

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=174161
Log:
	PR c++/47263
	* decl.c (use_eh_spec_block): Do use an EH spec block for a
	lambda op().

Added:
    branches/gcc-4_6-branch/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-eh2.C
Modified:
    branches/gcc-4_6-branch/gcc/cp/ChangeLog
    branches/gcc-4_6-branch/gcc/cp/decl.c
    branches/gcc-4_6-branch/gcc/testsuite/ChangeLog
Comment 3 Jason Merrill 2011-05-25 01:26:40 UTC
Fixed for 4.6.1.