Is there a reason for an empty return statement at the end of void function?

c++, return, syntax

Solution

There's no reason it needs to be there at the very end of a function, as far as I know. It's possible the function originally returned a value, someone changed it to a `void`, and just replaced `return value;` with `return;`. Or someone not very experienced with C++ assumed that every function must have a return, and will blindly believe this to the bitter end.

Now, a return in the middle of a function is definitely relevant since it stops the execution of the function at that point.

Problem

I was just looking at someone else's code and they have an empty return statement at the end of a void function: ``` void someFunction (int* someArg, int someArg2, int someArg3) { // some operations/function calls/recursion return; } ``` Is there a particular reason why it should be there?

Original source

Related problems