Bug 66026 - C++14] throw-expression is not a valid constant-expression
Summary: C++14] throw-expression is not a valid constant-expression
Status: RESOLVED DUPLICATE of bug 67371
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 5.1.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-05-05 18:45 UTC by rhalbersma
Modified: 2015-08-28 05:30 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description rhalbersma 2015-05-05 18:45:29 UTC
g++ 5.1.0 and current trunk 20150505 won't compile the following code with -std=c++1y:

constexpr auto fun(int n)
{
    switch(n) {
    case 0: return 0;
    default: return throw 42, 42;      
    }
}
    
int main()
{
    static_assert(fun(0) == 0, "");    
}

yielding the error: expression '<throw-expression>' is not a constant-expression

The same code compiles with -std=c++14 with all recent Clang versions (3.4.0 through SVN trunk).
Comment 1 Markus Trippelsdorf 2015-08-28 05:30:03 UTC
Lets merge this one with pr67371.

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