r/C_Programming • u/Just_Government3790 • Sep 12 '26
Question What C function would you delete and rewrite first, and why?
For me it's fnmatch - mostly because it's 40 year's old and smell's funny.
94
Upvotes
View all comments
Show parent comment
1
u/flatfinger Sep 15 '26
My point is that the way clang and gcc process things creates "artificial" side effects whose consequences are totally unpredictable and which directly contradict the behavior of the code as written. Treating a program as a sequence of steps, the above function would never perform any step that would be capable of writing past element 32768 of arr, but the machine code clang and gcc would generate if a function caller ignores the return value could perform an out-of-bounds store.