https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89830

Dominique d'Humieres <dominiq at lps dot ens.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING
   Last reconfirmed|                            |2019-03-27
     Ever confirmed|0                           |1

--- Comment #7 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
AFAIU this PR reports two issues with no or little connection with REPEAT.

(1) The program name conflict with an intrinsic procedure:

program precision
real :: x
print *, precision(x)
end program precision

which gives the error (for any OS)

    3 | print *, precision(x)
      |                  1
Error: Symbol at (1) is not appropriate for an expression

that is not really user friendly.

(2) The reference to the source in run time errors:

subroutine foo(s,n)
  implicit none
  character(len=1), intent(in) :: s
  integer, intent(in) :: n
  write(*,*) repeat(s,n)
end subroutine

call foo('a', -1)
end

which gives

% gfc pr89830_2_db.f90
% ./a.out
At line 5 of file pr89830_2_db.f90
Fortran runtime error: Argument NCOPIES of REPEAT intrinsic is negative (its
value is -1)
% gfc ../bug/pr89830_2_db.f90
% ./a.out
At line 5 of file ../bug/pr89830_2_db.f90
Fortran runtime error: Argument NCOPIES of REPEAT intrinsic is negative (its
value is -1)
% gfc /Users/dominiq/Documents/Fortran/g95bench/win/f90/bug/pr89830_2_db.f90
% ./a.out
At line 5 of file
/Users/dominiq/Documents/Fortran/g95bench/win/f90/bug/pr89830_2_db.f90
Fortran runtime error: Argument NCOPIES of REPEAT intrinsic is negative (its
value is -1)

i.e., the path to the file given to the compiler. AFAICT this is generic to all
run time error pointing to a source file (mostly I/O errors).

>From comment 5, the reporter's expectation is not clear for me. IMO this should
be solved at the build script level rather that with yet another option.

Note that not all the intrinsic give nice errors

PROGRAM test_spread
  INTEGER :: a = 1, b(2) = (/ 1, 2 /), n=-2
  WRITE(*,*) SPREAD(A, 1, n)            ! "1 1"
  WRITE(*,*) SPREAD(B, 1, n)            ! "1 1 2 2"
END PROGRAM

gives

Operating system error: Cannot allocate memory
Integer overflow in xmallocarray

and not

Fortran runtime error: Argument NCOPIES of SPREAD intrinsic is negative

Reply via email to