Thursday, November 4, 2010

Return Statements

When a non-main function is supposed to return a value, but doesn't; the result is undefined behavior.

I have had some experience with this. There was a function that had return statements in some, but not all branches. The program worked fine for years, returning 0 in cases where there were no return statements; but then the function started returning non-zero values, causing problems for the system.

No comments:

Post a Comment