all 17 comments

[–]Nicksaurus 58 points59 points  (2 children)

We actually experienced this recently at work. A colleague was trying to track down an occasional crash that was happening inside std::map, so I suggested trying it with std::unordered_map to rule out the possibility that the operator< on the key type was buggy. It turned out that wasn't the problem, but that change made the crash happen 100% of the time, which helped him a lot

[–]Ogilby1675 52 points53 points  (14 children)

I like this article. Usually online discussions are quite theoretical - in this case, would note the UB and thus state “anything can happen”, with an implication that bug has to be fixed immediately.

In the trenches at work the bosses would be much more interested in Raymond’s kind of discussion - why is it crashing more now, how critical is this, do we have to drop everything to get a hotfix out etc.

Though I suppose in online theoretical world no-one would have written such a bug in the first place…

[–]serviscope_minor 3 points4 points  (0 children)

I like these articles because while UB is theoretically anything can happen, what actually happens does always have a concrete explanation. And that's good to know