Bug 56388 - [4.7/4.8/4.9 regression] catch(...) in lambda rejected
Summary: [4.7/4.8/4.9 regression] catch(...) in lambda rejected
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.8.0
: P3 normal
Target Milestone: 4.7.4
Assignee: Jason Merrill
URL:
Keywords: c++-lambda
: 57143 57995 (view as bug list)
Depends on:
Blocks: lambdas
  Show dependency treegraph
 
Reported: 2013-02-19 06:23 UTC by omawarisan.bokudesu
Modified: 2022-03-11 00:32 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2013-04-09 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description omawarisan.bokudesu 2013-02-19 06:23:53 UTC
"g++ -std=c++11" rejects the following program:

int main()
{
    bool /*const*/ condition = false;

    [&]{
        try{}
        catch(...){
            if(condition){}
        }
    }();
}

If the condition variable is const, the compilation successes.

Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/home/user/gcc-trunk/libexec/gcc/x86_64-unknown-linux-gnu/4.8.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc/configure --prefix=/home/user/gcc-trunk --disable-bootstrap --disable-multilib --enable-languages=c,c++,fortran --with-gmp=/home/user/gcc-trunk/src/build/backends --with-mpfr=/home/user/gcc-trunk/src/build/backends --with-mpc=/home/user/gcc-trunk/src/build/backends
Thread model: posix
gcc version 4.8.0 20130219 (experimental) (GCC)
Comment 1 Daniel Krügler 2013-02-19 09:23:34 UTC
The problem also exists for 4.7.2, so no regression. The diagnostics is interesting:

"7:9: error: '...' handler must be the last handler for its try block [-fpermissive]
catch(...){
^"
Comment 2 Jason Merrill 2013-04-11 21:52:36 UTC
It's a regression from 4.6.
Comment 3 Jason Merrill 2013-04-16 20:30:12 UTC
Fixed for 4.7.4/4.8.1/4.9.0.
Comment 4 Paolo Carlini 2013-05-02 12:02:19 UTC
*** Bug 57143 has been marked as a duplicate of this bug. ***
Comment 5 Paolo Carlini 2013-07-26 16:25:47 UTC
*** Bug 57995 has been marked as a duplicate of this bug. ***