Fix libgomp Fortran tests

Brooks Moses bmoses@stanford.edu
Fri Sep 8 06:40:00 GMT 2006


Roger Sayle wrote:
> On Thu, 7 Sep 2006, Steve Kargl wrote:
>>The Fortran tried to use the most negative integer value, but
>>this cause an overflow because gfortran creates this value
>>via a unary minus operation.
> 
> Whilst I agree completely that prohibiting the constant -2147483648
> adheres to the letter of the standards, might it not be reasonable
> to support this as a STD_GNU or a STD_LEGACY extension for compatability
> with other compilers (such as previous versions of gfortran and g77)
> that are more forgiving in the constants that they accept.
> 
> I'm curious how many other F90/F95 compilers (dis)allow -2147483648?

I've been poking at this trying to figure out exactly what the rules 
are, and I will note that I think there's an interesting hair to split here.

By R305, a constant can be a literal-constant, which can by R306 be an 
int-literal-constant (but not a signed-int-literal-constant), and thus 
using -2147493648 in an assignment implies that it is to be interpreted 
as the positive value with a unary operator applied, and that positive 
value is out of range.

However, in a DATA statement, the values are not "constants", they are 
"data-stmt-constants", defined in rule R540, and these use signed 
literal constants (including signed-int-literal-constant) rather than 
unsigned ones.  As expressions are not allowed as DATA statement values, 
the interpretation of a negative integer remains unambiguous.

Thus, while

   INTEGER J = -2147493648

is not permitted,

   INTEGER J
   DATA J / -2147493648 /

is permitted.  (Note that 4.3.1.1, line 25, explicitly states that "Any 
integer value may be represented as a signed-int-literal-constant.")

- Brooks



More information about the Fortran mailing list