Alright, compiler devs, hackers, programming language designers and standardization folks, and anyone else who wants to play, letβs try something:
π Tell me your favorite bug in a compiler, standard library or programming language below. π
Feel free to repost.
Trying to show something.
Ali Fed Ex: Olaf Curious
Thread with replies from mastodon
1/
What about speculative and out of order execution? We still teach algorithms and introduction to programming in Pascal style pseudo code or Python, Java, whatever ...
Assuming the programmer is EXCLUSIVELY in charge of the control flow.
Until the program meets a real CPU. Downright evil, IMHO.
I spent days trying to get a basic QtQuick app working on a Raspberry Pi, until I tracked down the problems to Clang miscompiling the JS interpreter when targeting ARM CPUs.
I'm not sure why (NaN-boxing?) but the code had something like this, bit-casting a float to an integer: uint64_t handle_sqrt(double x) { double result = sqrt(x); return *(uint64_t*)&result; } LLVM assumed it could tail-call here: jump to sqrt instead of calling it, save a stack frame.
But floats and integers are returned on different registers, so that doesn't work! After calling sqrt it still needs to move from the float register to r0.
The caller was getting leftover register garbage instead of the actual result.
An LLVM developer quickly came up with a few lines of LLVM IR that reproduced the problem (bypassing the whole Clang compiler), and a fix. At the time I understood neither π
I found one in Turbo C/C++ back in the DOS days; turned out a register was getting saved but not restored. I think it was DX. Looong time ago.
I also vaguely remember a case in an early Turbo Pascal where the documentation said that a certain function destroyed certain registers when called, but it actually destroyed more⦠but that was just young me learning the hard realities about printed documentation.
@patigallardo.bsky.social My class hierarchy used covariance and multiple inheritance at the same time. Turned out EGCS (old C++ compiler) hadnβt implemented it. Guess I was the only person crazy enough to try it.
This reminded me of another compiler bug we had a work around for in Opera. Pretty sure that was also sqrt, but on Solaris and/or Spark (we supported some weird stuff).
RE: https://bsky.app/profile/did:plc:mlabzvj2dn2ynqufgidmh2i4/post/3n363d26fck2z
I haven't really done compiler-level stuff since uni (where the compiler I wrote for a course presumably was full of bugs, but that's lost to the mists of time).
But on a higher-level framework thing I was going to help port to a new platform for a different team, the thing just wouldn't build.
I found a bug by accident in the Microsoft implementation of std::variant (C++) years ago. I canβt find it. I think I just posted on my deleted twitter account. Iirc @tartanllama.xyz@bsky.brid.gy reported it. It mightβve been in the middle of the pandemic? Possibly in my DOOM port to C++ side quest?
Think Winniethepooh