logoalt Hacker News

tsimionescu • today at 4:00 PM • 1 reply • view on HN

There is a vast difference between IDB and UB. IDB is perfectly fine to rely on for your compiler, but it means your program may not be portable to other compilers.

UB means your program is not a C program and has no semantics whatsoever past the point it reaches the UB. The compiler is thus free to assume that the point that the UB would happen can't be reached and optimize in accordance to that assumption - which many modern compilers do, with often unexpected consequences (such as the infamous case of removing an integer overflow check in Linux because an_int+1>an_int is guaranteed to be true in the C abstract model).


Replies

cowlevel • today at 4:02 PM

How does gcc document integer to pointer conversion?

➕ show 1 reply