I wrote a simple function to return a string for me to display on the screen.
static std::string  myFun(int myId){
  std::ostringstream stream;
  int myStatus;
  if(get_status(&myStatus)) stream << get_error();
  else{
    stream << "my status:" << myStatus;
  }
    return stream.str();
}
The code itself is probably not important. But I include it just in case.The problem I encountered is because in my original attempt, I forget to include the return statement
return stream.str();
The compiler compiled with no error, but when I run it. The program keep getting messages like
Aborted(core dumped)
I freak out and I search I stackoverflow and installed valgrind and everything. Then I check the code, I realize I simply forget to include the return statement! I would expect the compiler to notice these kinds of mistake.
Can someone explain to me why the compiler cannot detect the error?
 
     
    