I had, and have since corrected, something like the following code:
class SomeClass {
public:
static int AdjustValue(float input);
static int DoSomethingWithAdjustedValue(int adjustedInput);
static int DoSomethingWithNormalValue(float input) {
DoSomethingWithAdjustedValue(AdjustValue(input);}
};
So DoSomethingWithNormalValue is clearly missing a return, but GCC did not generate an error or a warning for it. And places where I was calling DoSomethingWithNormalValue were getting the correct return code. I can think of two explanations for this:
-
There is some extension in GCC that recognizes inline functions that are wrapping other functions and passes the return values along.
-
The return code was being passed along because of a lucky/unlucky manifestation of undefined behavior combined with a bug in GCC that prevented any error or warning.
Neither of these strike me as being likely. What is going on here?
try:
I think you will find this is what happens.
Technically it is undefined behavior.