[PATCH] Document arithmetic overflow semantics

Segher Boessenkool segher@koffie.nl
Sun Feb 16 05:52:00 GMT 2003


Robert Dewar wrote:

> Yes, and that intuition is dangerously misleading, because it gives a false
> sense of comfort. If I tell you that an uninitialized variable could cause
> the system disk to be deleted, you will tend to react "yeah, yeah, we know
> this language lawyer stuff, but in practice, no implementor is going to
> do something that silly". However, once you allow an optimizer to back
> propagate the assumption that a program has a defined behavior, things
> may get surprising, and as you can see from my earlier message, there is
> a not too far fetched scenario in which a well meaning implementation could
> in fact end up deleting the system disk unintentionally as an indirect
> consequence of an uninitialized variable.

Yes, but won't such a program always give a compile-time
warning like "this branch will never be executed" or
"unreachable code deleted"?  Can you give an example
where the compiler will delete a branch but where it
is not able to diagnose it did?


Segher




More information about the Gcc mailing list