fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int* foo() {
  5. int arr[1] = { 42 };
  6. return arr;
  7. }
  8.  
  9. int main() {
  10. // your code goes here
  11. int x[1] = foo();
  12. return 0;
  13. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int* foo()’:
prog.cpp:5:6: warning: address of local variable ‘arr’ returned [-Wreturn-local-addr]
  int arr[1] = { 42 };
      ^~~
prog.cpp: In function ‘int main()’:
prog.cpp:11:17: error: array must be initialized with a brace-enclosed initializer
  int x[1] = foo();
                 ^
stdout
Standard output is empty