The loop for (; arg1 != arg2; ++arg1) will never end if the initial values are 1 and 1. You start it with ++arg1 this means that the first iteration will begin from incrementing arg1 and compare 2!=1 then 3!=1 etc.
for (; arg1 != arg2; ++arg1)
++arg1