Y
Hacker News
new
|
ask
|
show
|
jobs
by
AvImd
2251 days ago
> If the compiler aborted compilation when it detected undefined behavior, you’d be getting a lot of false positives for unreachable code
Could you please provide an example of this?
1 comments
toasted_flakes
2251 days ago
Overflow of signed integers is undefined.
int add(int a, int b) { return a + b; }
Unless the compiler can prove that `add` is never called with a and b values resulting in an overflow, this code can lead to UB, and, under your rules, the compilation aborts.
link