Cap'n'Proto remote vuln: pointer overflow check optimized away by compiler
For people claiming that this is a compiler bug, it really is not.<p>I am no expert, but what I understood is that the C standard defines some situations (such as an overflow error) which result in &quot;undefined behaviour&quot;. In this situation, the compiler is free to do whatever he wants. This is in fact what happens here.<p>This is clearly annoying to programmers. In this case, it is even hard to avoid undefined behaviour even if the source of undefined behaviour (a pointer overflow) is known.<p>Why is this done? This way the compiler can do some aggresive optimizations which are only valid if there is no undefined behaviour (e.g. no overflow, null pointer acces...).<p>There are various good articles about this.<p>To make the situation more complex for programmers, it is possible to write programs which exhibit undefined behaviour but work fine in practice. Until the compiler tries to do a specific optimization.<p>This is basically why you shouldn&#x27;t use C. Long-time C programmers know a list of operations which are undefined behaviour, and are usually able to point out a few of these in a program written by newbie (ironically, these programs may run and pass tests just fine).