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.
95
Upvotes
View all comments
Show parent comment
1
u/flatfinger Sep 14 '26
I'm not sure how "cleanly omitted" is in any way ambiguous. Consider the following function:
A compiler that processes the
whileas written could rely upon the fact that theifwill only be reached ifxis less than 32768. Cleanly omitting the while would make it possible for theifto be reached with a larger value ofx, thus making it necessary for the compiler to generate code for theifthat accommodates that possibility. The clang compiler (and gcc when in C++ mode) will process calls totest()that ignore the return value as unconditional stores toarr[x]*.*