On Sunday, 14 May 2017 at 12:07:40 UTC, Timon Gehr wrote:
On 14.05.2017 11:42, Patrick Schluter wrote:
But completely removing the code when one encounters for example:
if(val+1 == INT_MIN) is simply nuts.

Why? This is simple dead code elimination. The programmer clearly must have known that it is dead code and the compiler trusts the programmer. The programmer would _never_ break that trust and make a program evaluate INT_MAX+1 !

Well, actually, it makes sense to issue a warning in C.

But in C++ it makes less sense since meta-programming easily can generate such code without breaking the semantics of the program.

The corollary to 'trust the programmer' is 'blame the programmer'. Don't use C if you want to blame the compiler.

Oh well, there are lots of different checkers for C, so I guess it would be more like "don't blame the compiler, blame the verifier".

Reply via email to