Issue
I got a crash when a non void function like this didn't return anything:
bool ClassA::foo() {
//---do something---
}
void ClassA::foo2() {
foo();
}
Please note that the return value of this function was not used. And the crash is 100% reproducible. It crashes every-time. Ideally it should produce a warning and if I am not using the return value, it shouldn't crash.
This C++ code is compiled on Android NDK-version r19.
Also same code was working fine on NDK-r15c.
Is there any latest change?
Solution
I got a crash when a non void function like this didn't return anything:
Because this is Undefined Behavior.
§8.6.3 of the draft C++20 standard:
flowing off the end of a [non-void] function other than main results in undefined behavior.
Note that this is unrelated to how the function is actually called. So even when the return value is ignored (as in the case of the OP), it's the "flowing off the end" that results in UB.
Answered By - Paul Evans
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.