logoalt Hacker News

em3rgent0rdryesterday at 6:51 PM1 replyview on HN

Well because it could lead to any result on some platform or compiler, it invalidates assumptions about the program.


Replies

LoganDarkyesterday at 8:59 PM

UB invalidates assumptions about the program not necessarily because it leads to arbitrary behavior in practice, but because it leads to arbitrary behavior in spirit. Even if there is no compiler in existence where the UB causes a problem, that does not make the program correct. UB is about whether the program is correctly defined, not about whether it works or not.