logoalt Hacker News

nilamoyesterday at 12:03 PM2 repliesview on HN

This looks like a long back and fourth, that can easily be solved by a minute or two on godbolt...


Replies

aw1621107yesterday at 12:15 PM

> that can easily be solved by a minute or two on godbolt...

Unfortunately it's not that simple when it comes to UB. If the snippet in question does in fact exhibit UB then there's no guarantee whatever Godbolt shows will generalize to other programs/versions/compilers/environments/etc.

show 1 reply
saagarjhayesterday at 12:18 PM

No, compilers will often choose to not optimize on UB.