|
|
|
|
|
by adrian_b
1690 days ago
|
|
You need not imagine an alternate version of C, such a version of C is provided by any decent C compiler. For example, with gcc you can use either the option "-ftrapv" or the better option
"-fsanitize=undefined -fsanitize-undefined-trap-on-error"
and the program will abort on integer overflows (with the second option it will also abort for many other error conditions, e.g. access out of bounds). |
|
Classic misunderstanding of undefined behaviour. In this case it's still undefined behaviour, but the vendor has said "this is what my compiler will do with this particular undefined behaviour under these circumstances". Vendors are allowed to do anything they want when code containing undefined behaviour is submitted to their compiler, including doing something you might consider sane.