fork download
  1. // Example in C++14 Standard (ISO/IEC 14882:2014), Section 7.1.5, Paragraph 5.
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. constexpr int f(bool b){ return b ? throw 0 : 0; } // OK
  6.  
  7. constexpr int f() { return f(true); } // ill-formed, no diagnostic required
  8.  
  9. int main(){
  10.  
  11. try{
  12. f();
  13. }catch( int x ){
  14. cout << "x = " << x << endl;
  15. }
  16.  
  17. return 0;
  18. }
Success #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout
x = 0