This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Document arithmetic overflow semantics


> 
>     This is indeed the reason that Ada 95 introduced bounded errors,
>     where the language allows the implementation to pick any value
>     in the base range of the type or raise an exception.
> 
> I think that's intuitively what most of us mean by "undefined" in this
> discussion but you are quite right that it's good to formalize it better.

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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]