Ada front-end depends on signed overflow

Bernd Schmidt bernds_cb1@t-online.de
Wed Jun 8 16:12:00 GMT 2005


Paul Schlie wrote:
>>From: Robert Dewar <dewar@adacore.com>
>>You keep saying this over and over, but it does not make it true. Once
>>again, the whole idea of making certain constructs undefined, is to
>>ensure that efficient code can be generated for well defined constructs.
> 
> 
> - Can you give an example of an operation which may yield an undefined
>   non-deterministic result which is reliably useful for anything?

The simplest example is a shift operation, x << n, where the compiler 
may assume that the shift count is smaller than the width of the type. 
All sane machines agree on shift behaviour for 0 <= n < width, but there 
are differences between machines for n >= width.  Since this case is 
undefined by the language, it is ensured that shifts take only a single 
instruction on essentially all machines.


Bernd



More information about the Gcc mailing list