This is the mail archive of the gcc-patches@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: [Patch, Fortran] Use -huge()-1 as most negative integer for maxval/maxloc (PR30512)


Tobias Burnus wrote:
As FX pointed out: "If I understand the standard correctly, -huge()-1,
although being representible by the hardware you have, is not "within
the representation" of this integer kind, because the range of the
representation of an integer kind is supposed to be symmetric."

I'm going to disagree with that. The Fortran standard is generally quite clear when it's referring to the "model representation", as (for example) in the definition of HUGE(X): "Returns the largest number of the model representing numbers of the same type and kind parameter as the argument".


In the definition of MAXVAL(), it is quite clear that it is _not_ referring to the model representation: "The negative number of the largest magnitude supported by the processor" is what is returned for a zero-sized array. This is clearly not referring to the model representation.

It is only the _model_ representation that is constrained to be symmetric. The actual processor representation is not constrained in that fashion, and the standard makes a quite clear point about not requiring the processor representation to exactly replicate the model. Thus, for the purposes of MAXVAL and the like, FX's point is not relevant.

(Actually, IMO it's never relevant -- for cases where the integer model representation matters, negative numbers never actually show up as values that an intrinsic is required to return. Thus, I do think a reasonable case can be made that unsigned integer kinds are compatible with the Fortran standard, though I know this is an unconventional position.... SELECTED_INT_KIND can never return them, of course, but that doesn't mean they can't exist.)

- Brooks


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