I'm cross-compiling using ARM/GNU C Compiler:6.3.1 with optimizations -O0. A simple function like this:
static uint8_t xyzzy(void) {
if (<predicate one>) {
return 1;
} else if (<predicate two>) {
return 2;
} else {
return 4;
}
}
results in an error message:
Error control reaches end of non-void function [-Werror=return-type]
Is it really the case that the compiler doesn't know that one of those return statements must always be executed? Or is it me that is confused? And what is a recommended fix?
(P.S.: No, this is not a duplicate of Control reach end of non-void function, since I do have an else
as the last clause.)