43 ms·
Would int foo(int x, int y) { return x+y; } compile? After all, this function can be called in a way that causes UB.
by robryk 4y ago
Would
int foo(int x, int y) { return x+y; }
compile? After all, this function can be called in a way that causes UB.
- eru 4y agoPresumably, that function would be a compiler error like this. Unless your program can prove, that the function is only ever called with arguments that don't hit UB.
- int_19h 4y agoI think what OP is saying is that it should compile and not have any UB, because signed integer overflow should be well-defined. (This is the case in e.g. C#.)