Comment by skydhash
6 days ago
> With that said, both can give you unexpected behavior, just in different ways.
Unexpected as in "I didn't know" is different than unexpected as in "I can't predict". GCC optimizations is in the former camp and if you care to know, you just need to do a deep dive in your CPU architecture and the gcc docs and codebase. LLMs is a true shot in the dark with a high chance miss and a slightly lower chance of friendly fire.
And every single developer is supposed to memorize GCC's optimizations so they never make a change that will optimize wrong?
Nah, treating undefined behavior as predictable is a fool's errand. It's also a shot in the dark.
What is that about memorization? I just need to know where the information is so I can refer to it later when I need it (and possibly archive them if they're that important).
If you're not trying to memorize the entirety of GCC's behavior (and keeping up with its updates), then you need to check if your UB is still doing what you expect every single time you change your function. Or other functions near it. Or anything that gets linked to it.
It's effectively impossible to rely on. Checking at the time of coding, or occasionally spot checking, still leaves you at massive risk of bugs or security flaws. It falls under "I can't predict".
2 replies →