Re:Ask HN: What's your worst undefined C story?
by phaedrus on Thursday October 17, 2019 @05:43PM
(#21286623)
Kind of in the same vein, some code I was porting to a newer C++ compiler had "int error = get_status(x);" and I got a warning that the variable "error" is never used. So I commented the line out. After I finished fixing about 1,000 such warnings, re-running the program showed it no longer performed its serial I/O communication function. Turned out "get_status(x)" should have been called "send_data(x)". What was arguably the most important line out of 10,000 lines in the the project had nothing to differentiate it as special, and performs it's work as a "side effect" of setting a flag variable which is never checked.
Of course, that's not a good way to seed randomness, so I think there's a real argument that the upstream code was, in fact, buggy.