EDIT: I see some comments saying the Mastodon post didn’t add anything to it. I agree!

I am a little new to posting so I thought it was polite to include the source.

It was late and at first glance my sleepy mind thought they just saw these two images coincidentally side by side on their phone. Not like it was just a single meme. LOL

Here’s the raw image for fellow meme collectors. :)

Original link: https://chaos.social/@gsuberland/116037932568933433

  • zerofk@lemmy.zip
    link
    fedilink
    arrow-up
    2
    ·
    6 hours ago

    There are many things in C++ that are “undefined behaviour”, UB (and several similar but technically different terms). These may or may not result in an error or warning at compile time. Worse, they usually lead to crashes or even seemingly random behaviour - even in code that is not directly tied to the UB.

    The easiest example is memory management and pointers. You can create a new object and assign it to a variable. If you then delete the object, the variable could still point to the deleted object’s memory. And if you use that variable, that’s UB. It will likely crash, but probably not right away, which can be very hard to diagnose.

    An interesting fact about UB is that optimisers may assume it does not exist. They can basically reason “well this code path would lead to UB, which can’t exist, so this code path can just be removed”. This could theoretically even affect code that runs before the UB.