[Bug fortran/89830] New: intrinsic repeat() is completely broken
zbeekman at gmail dot com
gcc-bugzilla@gcc.gnu.org
Tue Mar 26 15:57:00 GMT 2019
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89830
Bug ID: 89830
Summary: intrinsic repeat() is completely broken
Product: gcc
Version: 8.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: zbeekman at gmail dot com
Target Milestone: ---
Created attachment 46026
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=46026&action=edit
Broken repeat example
The non-elemental intrinsic string function REPEAT() is completely broken. With
GFortran 8.3.0 installed via macOS Homebrew the following program fails to
compile:
```Fortran
program repeat
implicit none
write(*,*) repeat('a',5)
end program
```
It was compiled with:
```
gfortran -o repeat repeat_deterministic.f90
```
and produces the following error message:
```
repeat_deterministic.f90:3:19:
write(*,*) repeat('a',5)
1
Error: Symbol at (1) is not appropriate for an expression
```
Furthermore, there is an error message embedded in the `REPEAT()` function
which breaks deterministic builds! It is unclear to me why the following
example compiles while the one above does not:
```Fortran
subroutine co_broadcast_c_char(a,source_image,stat,errmsg)
character(kind=c_char,len=*), intent(inout), volatile, target :: a
integer(c_int), intent(in), optional :: source_image
integer(c_int), intent(out), optional:: stat
character(kind=1,len=*), intent(out), optional :: errmsg
! Local variables and constants:
integer(c_int), allocatable :: a_cast_to_integer_array(:)
! Convert "a" to an integer(c_int) array where each 32-bit integer element
holds four 1-byte characters
a_cast_to_integer_array = transfer(a,[0_c_int])
! Broadcast the integer(c_int) array
call co_broadcast_c_int(a_cast_to_integer_array,source_image, stat, errmsg)
! Recover the characters from the broadcasted integer(c_int) array
a = transfer(a_cast_to_integer_array,repeat(' ',len(a)))
end subroutine
```
(This example is from OpenCoarrays 2.6.1, or you can find it at
https://github.com/sourceryinstitute/OpenCoarrays/blob/8ceb2ce8912f4f0d5317a6cce248d042b3942280/src/extensions/opencoarrays.F90#L590)
When compiled, even with the `-fno-working-directory` flag, the object file
still contains references to the full path to the source file:
```
$ strings
src/mpi/CMakeFiles/opencoarrays_mod.dir/__/extensions/opencoarrays.F90.o
Argument NCOPIES of REPEAT intrinsic is negative (its value is %ld)
At line 590 of file
/Users/ibeekman/Sandbox/OpenCoarrays/src/extensions/opencoarrays.F90
```
More information about the Gcc-bugs
mailing list