Let's Answer Ray's Question!
Ramon Santamaria asked why one compiler appeared to produce different behavior than others. The underlying technical reason is much more interesting than a simple answer of "undefined behavior".
A few days ago, Ramon “Ray” Santamaria, author of the popular library Raylib, posted the following code snippet and question on X:
As you can see from the screenshot, GCC and MSVC x64 appear to create binaries that behave “correctly” - or at least not obviously wrong - whereas MSVC x86 appears to produce a binary that behaves “incorrectly”.
Although many people replied to Ray’s post by saying, “it’s undefined behavior” - which is true, because there’s a missing null terminator - that’s not a complete answer. That only says why the execution is allowed to be different, not how it actually differs.
I thought this was a great opportunity to show how we would investigate behavior like this to determine the root cause. I’ve prepared two videos (and some “outtakes” with esoterica) that show this process.
In this first video, I walk through the entire “source language” side of the behavior to show what is actually causing it. I will be posting a second video shortly for people who can read ASM which shows how to go one layer deeper and look at an even more precise answer.
If you’d like to be emailed when the second video is posted, you can subscribe your email address to either our free or paid tiers using the button below.



