Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28632 Discussions

Fortran suspected bug in array constructor

john_harper
Beginner
727 Views
This program constructs an array of integer(8) numbers, warns that there is an out-of-range integer(4) value in it, and prints a wrong answer. There seems to be a bug in integer(8) array construction, as the two print statements in the program should have given the same output, and the one that doesn't construct an array is right. Evidence:

rimu[~]$ cat testbitsize.f90
print *, (/bit_size(1_8),huge(1_8)/)
print *, bit_size(1_8),huge(1_8)
end
rimu[~]$ ifort -V testbitsize.f90
Intel Fortran Compiler Professional for applications running on IA-32,
Version 11.1 Build 20090630 Package ID: l_cprof_p_11.1.046
Copyright (C) 1985-2009 Intel Corporation. All rights reserved.
FOR NON-COMMERCIAL USE ONLY

Intel Fortran 11.1-2536
testbitsize.f90(1): warning #6384: The INTEGER(KIND=4) value is
out-of-range.
print *, (/bit_size(1_8),huge(1_8)/)
-------------------------^
GNU ld version 2.17.50.0.6-14.el5 20061020
rimu[~]$ ./a.out
64 -1
64 9223372036854775807
rimu[~]$

-- John Harper
0 Kudos
6 Replies
Kevin_D_Intel
Employee
727 Views

Thank you reporting this defect, John. It appears HUGE used in an array constructor returns an incorrect value. It does appear to function correctly in uses outside the array constructor, one which you showed. I reported this to Development (see internal tracking # below) and will update with new information as I learn it.

(Internal tracking id: DPD200159466)

(Resolution Update on 9/30/2012): This issue is resolved in the Intel® Fortran Compiler XE 2013 release (2013.0.079 – Linux).

0 Kudos
jimdempseyatthecove
Honored Contributor III
727 Views
I do not think this is a bug.

bit_size(1_8) returns an integer (INT4), huge(1_8) returns an INT8.
(/val1,val2/) now has two different types

What would you expect for

print*,(/1,2.3,'abc'/)


Try

print *, (/INT8(bit_size(1_8)),huge(1_8)/) ! should work

and

print *, (/INT8(bit_size(1_8)),INT8(huge(1_8))/) ! explicit of what you want

Jim Dempsey
0 Kudos
mecej4
Honored Contributor III
727 Views
Jim, the draft of the F2003 standard states in article 13.7.16 that the function bit_size returns an integer of the same kind as its integer argument. Therefore, the OP's constructor does not contain heterogeneous items.
0 Kudos
jimdempseyatthecove
Honored Contributor III
727 Views
Quoting mecej4
Jim, the draft of the F2003 standard states in article 13.7.16 that the function bit_size returns an integer of the same kind as its integer argument. Therefore, the OP's constructor does not contain heterogeneous items.


Good, then this would seem to indicate that the error may be in "bit_size" returning integer and not integer of same kind as integer argument.

Jim

0 Kudos
jimdempseyatthecove
Honored Contributor III
727 Views
Just ran a test, bit_size(bit_size(1_8)) == 64

Must be something else.

Jim
0 Kudos
Kevin_D_Intel
Employee
727 Views

Development's assessment is the compiler front-end does not properly recognize the kind parameter in the array constructor.

(Resolution Update on 9/30/2012): This issue is resolved in the Intel® Fortran Compiler XE 2013 release (2013.0.079 – Linux).

0 Kudos
Reply