Re: Integers and standard



Steven G. Kargl wrote:
...
Note, it does not use signed-int-literal-constant. More importantly
Z'80000000' will be converted to either an INTEGER(8) or INTEGER(16)
(depends on the hardware and I'm using gfortran's kind type parameter
values) value prior to the assignment.

j.f90:2.24:

data i/Z'80000000'/
1
Error: Arithmetic overflow converting INTEGER(16) to INTEGER(4) at (1)

I don't have gfortran installed, so I can't test it, but what does
it do if you overflow an integer expression at run-time? If
it doesn't abort then, why does it cause fatal error at compile-
time? The standard doesn't say what implementations should
do with overflow, but whatever it is should be consistent as
a quality of implementation issue.

--
J. Giles

"I conclude that there are two ways of constructing a software
design: One way is to make it so simple that there are obviously
no deficiencies and the other way is to make it so complicated
that there are no obvious deficiencies." -- C. A. R. Hoare

"Simplicity is prerequisite for reliability" -- E. W. Dijkstra


.



Relevant Pages

  • YCbCr to RGB
    ... embedded system. ... Now I came across a problem when converting from YCbCr ... If there is an overflow, ...
    (comp.compression)
  • Re: Typecast clarification
    ... Converting a *signed or unsigned* value to an unsigned ... SIG_DFL, and the Standard doesn't define how that handler behaves, ... Hence, undefined behaviour by omission. ... would assume that nearly all implementations take one out of at most a ...
    (comp.lang.c)
  • Re: YCbCr to RGB
    ... > as a thesis project I'm busy writing a small jpeg decoder for an ... > embedded system. ... Now I came across a problem when converting from YCbCr ... > If there is an overflow, ...
    (comp.compression)
  • Re: Conversion rules between unsigned operands and signed operand
    ... On some implementations of C, like mine and probably yours, ... INT_MIN probably expands to ... But does it mean "converting a negative value to an unsigned integer ...
    (comp.lang.c)
  • Re: not declaring something to equal null
    ... result of converting this value to int is implementation-defined ... (though it's likely to be 0 on many implementations). ... represented in an int, the behavior is undefined. ... "Any pointer type may be converted to an integer type. ...
    (comp.lang.c)