Yet another curious bug Posted on March 27, 2023March 28, 2023 by David I’m aware that C is notorious for unexpected behaviour (UB). Let me describe this bug: My second game in C + SDL for my newest eBook is Match Three and compiled with Clang-11 on my Raspberry Pi 4B. I’m getting a weird bug that doesn’t occur when I compile it on Windows under MSVC; the only differences between the source code on the PI and Windows are the paths to SDL and the sn._s calls but there aren’t many of those. Also I compiled it with clang-14 on Ubuntu 22.04 LTS on a Hyper-VM and that behaves properly. Each piece is held a struct in a 10 x 10 array. One field is called size. It’s 0 normally but if it is set to a value, typically 64 then it counts down, one per frame and the piece is drawn rotated by 8 degrees each frame. When it reaches 0 the piece is removed. This is my “down the plughole” way of removing pieces. It takes exactly 64/60 seconds to vanish. I use the size field to draw it when size is non-zero so it shrinks as it rotates It’s a nice effect. The bug though is that when it starts up, several pieces start rotating and keep rotating. The size field stays at 63. There’s no code that explains this behaviour and it only happens on the Raspberry Pi, not on Windows or on Ubuntu. Is it a compiler bug or some weird UB on the PI version. It’s an interesting bug and I’ve only wasted a week of evenings on it so far!