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


On Fri, Jun 03, 2005 at 06:25:27PM +0200, Florian Weimer wrote:
> There's also a fair amount of code whih relies on -1 ==
> (int)0xFFFFFFFF.

While that is not portable, -(1U) is portably all-ones, even on 36 bit
one's complement machines or other oddball architectures, since unsigned
types are required to obey the rules of modulo arithmetic.  Switching
to unsigned is usually the best thing to do if you want to assume that
overflow wraps.

Nevertheless, I frequently design software that is intentionally not
portable to all possible ISO C/C++ platforms (typically assuming
either ILP32 or LP64 with IEEE floating point arithmetic, with
tests to determine the behavior of certain unspecified operations
like the behavior of % with negative arguments).  However, the
nonportable constructs are only used when there is no portable
construct that is equally efficient.

OK, I know, this is getting off-topic.



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