"insane and pathological" is right on the money, haha. every single new thing I learn about C makes my jaw drop with horror
@silveradd49772 жыл бұрын
Hi Kris, very nice and in-depth tutorials on system programming. I have a question though: Using cc 6.3.0 on debian stretch, it seems the program selects two different addresses for both i and j, eventhough their lifetime has expired. Do you have any idea why this happens?
@silveradd49772 жыл бұрын
I am talking about the third example @ minute 26:58 where i and j are allocated inside two separated scopes within main
@johnnyappleprng6143 жыл бұрын
In the code around minute 21 ... try changing the number of elements in z ... and the output will be different than expected. When I copied the code Kris wrote verbatim... it produced: *a: 211 *a: 92 When I added an extra element to the end of z array, then the output was as Kris said it should be with the last element in z being written on the second line of output. Why? I am running debian 10 and using gcc with the basic default settings if that helps.
@eis3nheim2 жыл бұрын
I know you probably knew the answer by know, nevertheless the answer to your question is this is an *undefined behaviour* you can't expect everytime to replicate the result, for instance your OS could have written some value to that location when it became available, even for Kris's code behaviour it is not guaranteed to produce the same result on different machines.
@johnmorrison26452 жыл бұрын
My Mac M1 did this: MAC:Tue Sep 06:16:54:~> ./scopes i = 0 &i = 0x16fad7604 j = 1 &j = 0x16fad7600 *p = 0
@shanghengwu8254 Жыл бұрын
I also got the same result on my Mac, do you know the reason?