fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. constexpr void f (double speed)
  6. {
  7. constexpr double C = 299792.468;
  8. const double local_max = 160.0/(60*60);
  9. static_assert(local_max<C,"can't go that fast");
  10. }
  11.  
  12. int main()
  13. {
  14. f(3.25) ;
  15.  
  16. cout << "Reached here!";
  17. return 0;
  18. }
  19.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:9:16: error: static_assert expression is not an integral constant expression
        static_assert(local_max<C,"can't go that fast");
                      ^~~~~~~~~~~
prog.cpp:9:16: note: read of non-constexpr variable 'local_max' is not allowed in a constant expression
prog.cpp:8:15: note: declared here
        const double local_max = 160.0/(60*60);
                     ^
1 error generated.
stdout
Standard output is empty