https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78676
kargl at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
CC| |kargl at gcc dot gnu.org
Resolution|--- |INVALID
--- Comment #8 from kargl at gcc dot gnu.org ---
(In reply to janus from comment #4)
> This seems to be a regression that started with version 4.9. In 4.7 and 4.8
> I see the same results with all optimization levels.
It is not a regression. It is invalid code, so the compiler can generate
whatever results it wants. Fortran does not have an unsigned integer
type, which KISS requires.
13.7.1 General
Detailed specifications of the standard generic intrinsic
procedures are provided in 13.7 in alphabetical order.
The types and type parameters of standard intrinsic procedure
arguments and function results are determined by these specifications.
The "Argument(s)" paragraphs specify requirements on the actual
arguments of the procedures. The result characteristics are sometimes
specified in terms of the characteristics of dummy arguments.
A program is prohibited from invoking an intrinsic procedure under
circumstances where a value to be returned in a subroutine argument or
function result is outside the range of values representable by objects
of the specified type and type parameters, unless ... (stuff about IEEE).
13.3 Bit model
13.3.1 General
... (stuff about nonnegative integers) ...
The interpretation of a negative integer as a sequence of bits is
processor dependent.
13.7.78 IEOR (I, J)
... (stuff about IEOR) ...
The model for the interpretation of an integer value as a sequence of
bits is in 13.3.
13.7.84 ISHFT (I, SHIFT)
... (stuff about ISHFT) ...
The model for the interpretation of an integer value as a sequence of
bits is in 13.3.
OP has three options. 1) Change his/her code to use INTEGER(8) for
intermediate computations. Results can then be converted to
INTEGER(4) by "mod(result, HUGE(I))". 2) Use ISO C binding to call
a C implementation of KISS. 3) Use -fwrapv as indicated in comment #1.
BTW, until very recently, gfortran used 4 independent KISS generators
for random_number. BUt, that implementation was done in C.