fork(2) download
  1. #include <iostream>
  2. #include <type_traits>
  3.  
  4. const int* func() { return nullptr; }
  5.  
  6. int main() {
  7. const auto p = func();
  8. static_assert(std::is_same<decltype(p), const int* const>::value, "unexpected type");
  9. p = nullptr; // error: assignment of read-only variable ā€˜pā€™
  10. }
Compilation error #stdin compilation error #stdout 0s 4428KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:9:7: error: assignment of read-only variable ‘p’
   p = nullptr; // error: assignment of read-only variable ‘p’
       ^~~~~~~
stdout
Standard output is empty