logoalt Hacker News

Moldotecktoday at 12:11 PM1 replyview on HN

So how exactly would this shooting in the foot look like compared to say java


Replies

dminiktoday at 4:55 PM

Too many to list, but for some examples:

You take a reference to a vector element, which you later accidentally invalidate by pushing to the same vector.

You move out of a unique_ptr, but then you accidentally use it again.

You create a cycle with shared_ptr causing a memory leak.

If you std::sort a list of floats with NaNs (among other things) you can stomp over memory. The sort function requires some very specific ordering otherwise you get UB.

show 1 reply