Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!
26753 Discussions

Zero-sized array constructor curiosity

Ferdinand_T_
New Contributor II
204 Views

Even the most underwhelming Christmas present needs wrapping

print *, [[integer::]]
end

But on Linux, ifort 16,17,18,19(.0.3):

error #7203: An ac-value-list of an array-constructor must contain at least one ac-value.
print *, [[integer::]]

Also gfortran 9.1.0:

 1 | print *, [[integer::]]
      |
internal compiler error: in gfc_typenode_for_spec, at fortran/trans-types.c:1120

Nobody likes underwhelming Christmas presents.

0 Kudos
7 Replies
JohnNichols
Valued Contributor II
204 Views

Very interesting as Sgt Schultz would have said. 

I suggest another beer 

Steve_Lionel
Black Belt Retired Employee
204 Views

Peculiar. The extra set of brackets seems to be the key here. Note that this isn't specifying a rank-two array, since:

If an ac-value is a scalar expression, its value specifies an element of the array constructor. If an ac-value is an array expression, the values of the elements of the expression, in array element order (9.5.3.2), specify the corresponding sequence of elements of the array constructor.

Both compilers are wrong here, in different ways. Please report this to Intel using the Online Service Portal  You can report it on Bugzilla against gfortran.

Ferdinand_T_
New Contributor II
204 Views

Yeah, it is an interesting (...but also stupid) case, as the outer 'wrapping' brakets are pretty useless. I have reported it nevertheless. Thanks.

PS: concerning gfortran, this bug was reported in 2015 here https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65428

Steve_Lionel
Black Belt Retired Employee
204 Views

I've been seeing gripes from the few remaining gfortran developers that a lot of old, lower-priority bugs aren't getting worked on because there's no one to do so.

Devorah_H_Intel
Moderator
204 Views

Thank you for your report. This case has been escalated to compiler engineering.

JohnNichols
Valued Contributor II
204 Views

Steve:

What should it have done?

John

Steve_Lionel
Black Belt Retired Employee
204 Views

It should have printed a blank line since the I/O list was an empty (zero-element) array. The code shown is functionally identical to:

print *, [integer::]
end

(Note only one set of brackets.) This is a zero-element array of default integer type/kind.

To make it a bit more obvious:

print *, [integer::[1,2,3],4,5]
end

should print:

1  2  3  4  5

(ignoring spacing)

Reply