Bug 57995

Summary: [4.72, C++11] Lambda [&] wrongly states catch(...) must be the last handler when variable by-reference capture occurs within catch(...) scope
Product: gcc Reporter: devcontrib4590
Component: c++Assignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED DUPLICATE    
Severity: minor    
Priority: P3    
Version: 4.7.2   
Target Milestone: ---   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed:
Attachments: Example Code that shows 2 failures and 2 passing cases.

Description devcontrib4590 2013-07-26 16:04:07 UTC
Created attachment 30559 [details]
Example Code that shows 2 failures and 2 passing cases.

The following code snippet (see attachment for full code), produces the error, "error: ‘...’ handler must be the last handler for its try block [-fpermissive]", but explict capture of the variable rv, or usage of rv outside of the catch(...) scope.


// $ g++ --version
// g++ (GCC) 4.7.2 20121109 (Red Hat 4.7.2-8)
// Copyright (C) 2012 Free Software Foundation, Inc.
// This is free software; see the source for copying conditions.  There is NO
// warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//
// $ cat /etc/redhat-release 
// Fedora release 18 (Spherical Cow)
//
// $ uname -a
// Linux redacted 3.9.11-200.fc18.x86_64 #1 SMP Mon Jul 22 21:04:50 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

    bool rv;
    
    auto broken = [&] () 
    {
        try
        {
            
        }
        catch(...)
        {
            // Capturing a variable here produces an error related to exception handling
            rv=false;
        }
    };
Comment 1 Paolo Carlini 2013-07-26 16:25:47 UTC
Already fixed.

*** This bug has been marked as a duplicate of bug 56388 ***