pgf95 17.10 & 18.4 Allocatable dummy argument bug?

pgf95 17.10-0 64-bit target on x86-64 Linux -tp sandybridge

Surely it should not be necessary to specify INTEGER and ALLOCATABLE in the same statement?

      
      MODULE MYALLOCATE
C
      CONTAINS
C
      SUBROUTINE MY_ALLOC(B)
C
      INTEGER :: B                           !separate statements
      ALLOCATABLE :: B(:)                    !"fail"
c      INTEGER, ALLOCATABLE :: B(:)           !together works fine
c
      write(0,*)'my_alloc    ',size(b,1),lbound(b,1),ubound(b,1)
C
      RETURN
C
      END SUBROUTINE MY_ALLOC
C
      END MODULE MYALLOCATE
C-----------------------------------------------------------------------
      PROGRAM MAIN
C
      USE MYALLOCATE
C
      INTEGER :: A
      ALLOCATABLE :: A(:)
C
      ALLOCATE (A(2:500))
C
      A=0
c
      write(0,*)'size, lbound, ubound:'
      write(0,*)'main in     ',size(a,1),lbound(a,1),ubound(a,1)
C
      CALL MY_ALLOC(A)
c
      write(0,*)'main out    ',size(a,1),lbound(a,1),ubound(a,1)
C
      END PROGRAM MAIN

The failure to determine size, lbound, ubound is just an example of the nasty things to come
if you use this in a real life code…

Regards,
Nigel

Hi Nigel,

I was able to reproduce the incorrect answers with PGI so have added an issue report (TPR#25937) and sent it to our engineers for further investigation.

I tested the code with other compilers and found that gfortran and xlf give the expected output but Intel gives a syntax error (See below).

I’m not sure if the code is valid or not (I’ll let our language experts determine this), though if it is valid, we should give correct answers, if not, then we should give a syntax error.

Thanks for the report,
Mat

% pgfortran test.f; a.out
size, lbound, ubound:
main in 499 2 500
my_alloc 0 1 0
main out 499 2 500

% gfortran test.f ; a.out
size, lbound, ubound:
main in 499 2 500
my_alloc 499 2 500
main out 499 2 500

% ifort test.f
test.f(9): error #6427: This dummy scalar or array is invalid in this context. [B]
ALLOCATABLE :: B(:) !"fail"
---------------------^
test.f(12): error #6361: An array-valued argument is required in this context. [SIZE]
write(0,*)'my_alloc ',size(b,1),lbound(b,1),ubound(b,1)
------------------------------------^
test.f(12): error #6283: The DIM specification is out-of-range. [1]
write(0,*)'my_alloc ',size(b,1),lbound(b,1),ubound(b,1)
--------------------------------------^
test.f(12): error #6361: An array-valued argument is required in this context. [LBOUND]
write(0,*)'my_alloc ',size(b,1),lbound(b,1),ubound(b,1)
------------------------------------------------^
test.f(12): error #6283: The DIM specification is out-of-range. [1]
write(0,*)'my_alloc ',size(b,1),lbound(b,1),ubound(b,1)
--------------------------------------------------^
test.f(12): error #6361: An array-valued argument is required in this context. [UBOUND]
write(0,*)'my_alloc ',size(b,1),lbound(b,1),ubound(b,1)
------------------------------------------------------------^
test.f(12): error #6283: The DIM specification is out-of-range. [1]
write(0,*)'my_alloc ',size(b,1),lbound(b,1),ubound(b,1)
--------------------------------------------------------------^
test.f(22): error #7013: This module file was not generated by any release of this compiler. [MYALLOCATE]
USE MYALLOCATE
----------^
compilation aborted for test.f (code 1)

I tested the code with other compilers and found that gfortran and xlf give the expected output

Oracle Studio also gives the expected output.