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: Ada front-end depends on signed overflow


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



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