I have the following code sample:
void some_function()
{
int ret = do_something();
if(ret == SOME_ERROR)
return;
}
Afaik the last if
is useless as the function returns no matter what value ret
has. I'd expect a warning or at least an info by the compiler (I use GCC 6). I also tried to enable all warnings from this thread but still nothing. Is there any difference between returning with a return
statement and returning at the end of a void function or does it get optimized anyways (but I still think a warning would be useful then)?