Subj : return + goto compiler problem To : borland.public.cpp.borlandcpp From : Jan Bogaerts Date : Sat Mar 20 2004 05:52 pm I have the strangest compiler problem that I just can't seem to explain. Does anybody else have this and do you have an explanation for it. I am trying to compile the code: if(afunc())goto test; else goto test2; test: return; //doesn't get compiled test2: afunc2(); //doesn't get compiled goto a; the 2 lines indicated don't get compiled, but when I change the function to one with a return value (any type), it does compile: if(afunc())goto test; else goto test2; test: return false; //gets compiled test2: afunc2(); //gets compiled goto a; //also, when you leave out the final 'else' so you and with if or else if, it also compiles. The code itself isn't pretty with all the goto statements. It comes from a generator that doesn't have any other option than to use goto statements. I figure it's got something to do with the fact that the compiler thinks he can skip the code after the 'else goto'. Could this be a compiler fault, or am I wrong somewhere? .