I've started using CLang recently to compile embedded C++ ARM programs.
Prior to this I used GCC and C, almost exclusively for embedded work.
I've noticed that when I have a method that returns a value, and I forget the return statement, the program core dumps. There is no error printed other than "msleep error -1" from one of my device drivers. This is on FreeBSD.
I would expect that forgetting the return statement would just result in garbage being returned from the function, not a core dump.
EDIT: I'm returning a bool, not a pointer or object or anything complicated. The program crashes even when the return value doesn't matter.
What is going on?
E.G.:
bool MyClass::DummyFunc() {
<do some stuff and forget the return value>
}
Elsewhere:
if(pMyObj->DummyFunc()) {
print ("Hey, it's true!\n");
} else {
print ("Darn, it's false!\n");
}
That code should not crash, regardless of the return value.