I recently wrote a message: A
strange error in a C ++ program: deleting a print-out program
... in which I tried to solve a seemingly incomprehensible problem in which deleting the cout instruction would violate my program.
As it turned out, my problem was that I forgot to return the true / false success flag, which I later used for logic.
But, apparently, SOMETHING was returning and something was always true if I left this cut, but, it would seem, “magically” would become false when I pulled it out.
My question is for all of you:
What determines what a C ++ function returns when the return command is not executed in the function? Is there any logic?
Obviously, forgetting your return type is a bad idea. In this case, however, it was largely due to the nature of my program - fast work with hacking. Later, I decided that it was not worth the effort to implement an algorithm to determine the success / failure of a function call, but accidentally left a code depending on the return.
Bafflingly g ++ did not give me any warnings or errors when compiling the executable as follows:
g++ main.cc -g -o it_util
My version: g ++ (GCC) 4.1.2 20080704 (Red Hat 4.1.2-44)
Again, in order to preserve other future frustrations if they make the same stupid mistake and encounter the same seemingly unstable behavior, can anyone shed light on where the function without returning gets its return value from
Thank!!