Wandbox
SettingsLog
SettingsLog
Language
GitHubLogin
Ran/Viewed Log

Author

anonymous

about 1 year ago

Language

C++

Compiler

gcc 13.2.0

Options
Warnings
Don't Use Boost
C++17
-pedantic
Raw compiler options
-fsanitize=undefined

Author

anonymous

about 1 year ago

$ g++ prog.cc -Wall -Wextra -std=c++17 -pedantic -fsanitize=undefined
prog.cc: In function 'int& f()':
prog.cc:5:10: warning: reference to local variable 'i' returned [-Wreturn-local-addr]
    5 |   return i;
      |          ^
prog.cc:4:7: note: declared here
    4 |   int i = 1;
      |       ^
prog.cc: In function 'int& g()':
prog.cc:10:10: warning: reference to local variable 'j' returned [-Wreturn-local-addr]
   10 |   return j;
      |          ^
prog.cc:9:7: note: declared here
    9 |   int j = 2;
      |       ^
prog.cc:5:10: runtime error: reference binding to null pointer of type 'int'
prog.cc:10:10: runtime error: reference binding to null pointer of type 'int'
prog.cc:16:10: runtime error: load of null pointer of type 'int'
Signal:
Segmentation fault