Comment

Comment by Bjartr

> However, if your program avoids the code paths which trigger undefined behavior, then you are safe.

This seems incorrect as demonstrated by the other undefined behavior story I read on HN today[1], the tl;dr of which, as I understood it, is since UB is not allowed, the compiler can elide checks that would protect against UB for the sake of optimization since a correct program wouldn't have caused the UB in the first place and the compiler doesn't have to respect the semantics of incorrect programs.

[1] https://news.ycombinator.com/item?id=41146860

parent Bjartr 2 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton