Certainly there is a bug other than the one you think you've found, and I don't think the circumstances you mention demonstrate a bug at all.
I would certainly be interested in seeing a more detailed analysis.
I don't think I've found a real "bug" yet. You include, but don't use, stdlib.h; you exit with status 0, even on error; but these are nitpicks, not what you mean. I'll think a bit more.
I return 0 in all cases because my test succeeds, even if the routine it's testing fails. It's up to my shell to decide what to do about that error. As it stands it reports the error, but it has succeeded in doing so, so it hasn't failed.
But that's not the point, as you say.
And the real bug is still there.
Will you give out the answer at some point?
(OK, yes, for exceedingly large inputs there are issues about sizes of integers, etc., but that's not the bug. It's much, much simpler.)
Deleted comment
Deleted comment