Limited number of CALLs per line?
Posted: 21 Nov 2020 14:18
Hello,
I just encountered a very strange behaviour of the CALL command (on my Windows 7 x64 machine) when it tries to call a non-existent label and appears quite a number of times in a line:
As expected, the above code returns several time the same error message: "The system cannot find the batch label specified - SUB".
As mentioned in the comments, as soon as I add more CALLs, the error message no longer appears, and when I add enough CALLs, the fatal CALL stack overflow error occurs, although there should actually not occur a single call.
I am quite sure that the numbers mentioned in the script may vary depending on a lot of (yet unknown) things.
Does anyone have an explanation of what happens here?
Thanks 'n' cheers,
aschipfl
I just encountered a very strange behaviour of the CALL command (on my Windows 7 x64 machine) when it tries to call a non-existent label and appears quite a number of times in a line:
Code: Select all
@echo off
::The following contains 85 times `call :SUB` and complaints about a missing label as expected.
::Strangely, appending one more ` & call :SUB` prevents it from raising an error message.
::If you copy this line multiple times, nothing changes, the expected exception occurs.
::However, when appending ` & call :SUB` even to the last of the lines, nothing is returned.
::Even when you copy the augmented `call :SUB` line below the last `goto :EOF`, nothing is output.
call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB & call :SUB
::If there is `call` more than 128 times it complains about exceedance of the recursion stack limit:
goto :EOF
:FAKESUB
goto :EOF
As mentioned in the comments, as soon as I add more CALLs, the error message no longer appears, and when I add enough CALLs, the fatal CALL stack overflow error occurs, although there should actually not occur a single call.
I am quite sure that the numbers mentioned in the script may vary depending on a lot of (yet unknown) things.
Does anyone have an explanation of what happens here?
Thanks 'n' cheers,
aschipfl