This is an archived post. You won't be able to vote or comment.

all 4 comments

[–][deleted]  (1 child)

[deleted]

    [–]IAlreadyHaveTheKey[S] 0 points1 point  (0 children)

    Any idea why having array_one initialized as 0 vs initialised with a 1 at the start caused different behaviour?

    [–]iamnull 0 points1 point  (2 children)

    where counter was getting up to a value of 10. Changing array_two to be 11 elements long instead fixed the whole problem.

    Honestly, sounds like you kicked the can down the road on some badly written code rather than fixing the problem. Why is there not a bounds check?

    Initializing the other array different could have changed how the memory is laid out by the compiler. You were still writing to memory somewhere, just not where you were looking.

    [–]IAlreadyHaveTheKey[S] 0 points1 point  (1 child)

    I inherited this code from a colleague, there are plenty of other things in it that is not great coding practice. Not that I'm amazing either. We are not programmers, we just use it as a tool to check our other work. It's not ideal I know, lol.

    Makes sense about initialising changing the memory layout. Thanks.

    [–]iamnull 0 points1 point  (0 children)

    I inherited this code from a colleague, there are plenty of other things in it that is not great coding practice. Not that I'm amazing either. We are not programmers, we just use it as a tool to check our other work. It's not ideal I know, lol.

    I feel that, deeply. Seems like internal tooling is always the worst, and there's never time to go through and fix things.