syzygy wrote:Only just now I became aware of
this paralell thread, containing passages such as:
I clearly DO understand what "undefined behavior" means. I, unlike yourself, apparently, ALSO understand WHY the warning about overlapping source/destination is discouraged. I, unlike yourself, am perfectly capable of avoiding that particular pitfall, which lets me use strcpy() in a way that will absolutely NOT fail.
Ouch.
Wow, yeah, that thread has some real head-scratchers in it. If only I had read that one first, I could have saved some time writing reply posts in this thread. Its obvious bob has backed himself into a corner and needs to "win" the argument, and no amount of persuasion or even outright ridicule will overcome this. Myself, I would rather admit when I am wrong... learning new things is easier that way.
I just hope he's not teaching dangerously-wrong ideas about undefined behavior and program correctness to his C programming students.
I know if I was interviewing a job candidate and he told a story like the one that has unfolded here, and the punch-line was "they broke my code, NEVER break working code, even though my code was invoking undefined behavior its obviously their fault because the program _worked_" .. I would not hire that candidate, because of their
dangerously wrong ideas about whose responsibility it is to avoid undefined behavior.
Only the programmer has the power to write correct programs. Compilers can't take an incorrect program and paper it over to make it look like a correct one, nor should they try. Programs can
appear to be correct even when they aren't; those are not
working programs, they are broken programs with time-bombs in them, and "Works on my machine" is a mediocre retort after it has been pointed out that the program is incorrect.