Posts: 1,773
Threads: 47
Joined: Jan 2015
Reputation:
0
03.01.2017, 09:35
(
Last edited by Gammix; 03/01/2017 at 10:12 AM.
)
That's the difference between run time and compile time.
Like if you put a number itself 'array[10]', 10 is the size and index should be < 10; compiler gives you an error because 10 is a constant but if you use a variable, it can be anything, compiler cannot predict values, so you'll get run time in that case.
And "strcat" might have internal checks to avoid run time errors.
Edit: i misread strcat part, thats probably overwriting the EOS index of "array". Which i believe is a PAWN bug!
Posts: 694
Threads: 2
Joined: Oct 2012
Reputation:
0
That might be because next memory cells after array[10] is empty and it finally finds the EOS char 2 memory cells after array, but it still throws a runtime error as far as I remember and this is essentially what memory leaking is, gonna make serious problems later on if you don't fix it. (again I'm not sure how pawn works regarding memories, just a guess seeing as how pawn deals with these things in general.)
Edit: there was also a trick in one of Yashas' topics about this pawn trick/bug with static vars.
Posts: 1,939
Threads: 11
Joined: Oct 2015
Reputation:
0
All initialisation occurs on runtime so compiler won't detect them as they can't predict the variables(name itself says) but only constants if you used const keyword then compiler would give error.
Posts: 1,578
Threads: 15
Joined: Feb 2013
Reputation:
0
I'm not talking about the compiler not detecting them, I'm talking about why the array actually holds that string, even though its length is bigger than the array's size.
Posts: 1,578
Threads: 15
Joined: Feb 2013
Reputation:
0
It's not really a problem since I never actually do that, but it just happened by mistake and it got me wondering.
Anyway, thank you for the replies.