findloc and gfortran 9.1.1

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

findloc and gfortran 9.1.1

Kay Diederichs
Dear all,

I installed devtoolset-9-gcc-gfortran on CentOS-7 which has gfortran 9.1.1 .

The following works as expected:
-----------------
cat >temp.f90 <<eof
integer array(10)
array=1
array(5)=2
print*,findloc(array,2,dim=1)
end
eof
gfortran temp.f90 && ./a.out
-----------------
           5


The following gives an internal compiler error:
-----------------
cat >temp.f90 <<eof
character array(10)*1
array='1234567890'
print*,findloc(array,2,dim=1)
end
eof
gfortran temp.f90 && ./a.out
-----------------
temp.f90:4:21:

    4 | print*,findloc(array,2,dim=1)
      |                     1
internal compiler error: Cannot convert ‘INTEGER(4)’ to ‘CHARACTER(1)’
at (1)
Please submit a full bug report,
...

And the following:
-----------------
cat >temp.f90 <<eof
character array(10)*1,value*1
array='1234567890'
value='5'
print*,findloc(array,value,dim=1)
end
eof
gfortran temp.f90 && ./a.out
-----------------
/scratch/opt/rh/devtoolset-9/root/usr/bin/../libexec/gcc/x86_64-redhat-linux/9/ld:
/tmp/cchFiFi7.o: in function `MAIN__':
temp.f90:(.text+0xfc): undefined reference to `_gfortran_findloc2_s1'
collect2: error: ld returned 1 exit status

While the first example works as expected, the second and third examples
show that findloc's implementation is not mature.
In which version were these bugs corrected?

thanks,
Kay

Reply | Threaded
Open this post in threaded view
|

Re: findloc and gfortran 9.1.1

gcc - fortran mailing list
Hi Kay,

> The following gives an internal compiler error:
> -----------------
> cat >temp.f90 <<eof
> character array(10)*1
> array='1234567890'
> print*,findloc(array,2,dim=1)
> end
> eof
> gfortran temp.f90 && ./a.out
> -----------------
> temp.f90:4:21:
>
>      4 | print*,findloc(array,2,dim=1)
>        |                     1
> internal compiler error: Cannot convert ‘INTEGER(4)’ to ‘CHARACTER(1)’
> at (1)

That is https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93498 , which has
been fixed for 9.3 and trunk.

> character array(10)*1,value*1
> array='1234567890'
> value='5'
> print*,findloc(array,value,dim=1)
> end
> eof
> gfortran temp.f90 && ./a.out
> -----------------
> /scratch/opt/rh/devtoolset-9/root/usr/bin/../libexec/gcc/x86_64-redhat-linux/9/ld:
> /tmp/cchFiFi7.o: in function `MAIN__':
> temp.f90:(.text+0xfc): undefined reference to `_gfortran_findloc2_s1'
> collect2: error: ld returned 1 exit status

This probably means that you are picking up the wrong shared
library from somewhere.

Try "ldd ./a.out" to see where this is pointing. Alternatively,
using -static-libgfortran should also work.

One remark, the expected output of your proogram above is 0.

> In which version were these bugs corrected?

You are an optimist for thinkging that they have been corrected,
but you are right in this case :-)

Regards

        Thomas
Reply | Threaded
Open this post in threaded view
|

Re: findloc and gfortran 9.1.1

Kay Diederichs
Hi Thomas,

On 4/9/20 1:19 PM, Thomas Koenig via Fortran wrote:

> Hi Kay,
>
>> The following gives an internal compiler error:
>> -----------------
>> cat >temp.f90 <<eof
>> character array(10)*1
>> array='1234567890'
>> print*,findloc(array,2,dim=1)
>> end
>> eof
>> gfortran temp.f90 && ./a.out
>> -----------------
>> temp.f90:4:21:
>>
>>      4 | print*,findloc(array,2,dim=1)
>>        |                     1
>> internal compiler error: Cannot convert ‘INTEGER(4)’ to ‘CHARACTER(1)’
>> at (1)
>
> That is https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93498 , which has
> been fixed for 9.3 and trunk.
>
>> character array(10)*1,value*1
>> array='1234567890'
>> value='5'
>> print*,findloc(array,value,dim=1)
>> end
>> eof
>> gfortran temp.f90 && ./a.out
>> -----------------
>> /scratch/opt/rh/devtoolset-9/root/usr/bin/../libexec/gcc/x86_64-redhat-linux/9/ld:
>> /tmp/cchFiFi7.o: in function `MAIN__':
>> temp.f90:(.text+0xfc): undefined reference to `_gfortran_findloc2_s1'
>> collect2: error: ld returned 1 exit status
>
> This probably means that you are picking up the wrong shared
> library from somewhere.
>
> Try "ldd ./a.out" to see where this is pointing. Alternatively,
> using -static-libgfortran should also work.
>
> One remark, the expected output of your proogram above is 0.
>
>> In which version were these bugs corrected?
>
> You are an optimist for thinkging that they have been corrected,
> but you are right in this case :-)
>
> Regards
>
>     Thomas
>

thanks, your answer put me on the right track!

The third example was the one I was really interested in, and -static-libgfortran is a specific fix.
When I look at /opt/rh/devtoolset-9/root/usr/lib/gcc/x86_64-redhat-linux/9/libgfortran.so , it is just

/* GNU ld script
   Use the shared library, but some functions are only in
   the static library, so try that secondarily.  */
OUTPUT_FORMAT(elf64-x86-64)
INPUT ( /usr/lib64/libgfortran.so.5 )

and therefore points to /usr/lib64/libgfortran.so.5 which is installed by a rather old RPM called
libgfortran5-8.3.1-2.1.1.el7.x86_64 . This has no support for findloc, as verified by
nm -D /usr/lib64/libgfortran.so.5 | grep -i findloc

So either using -static-libgfortran, or just removing /opt/rh/devtoolset-9/root/usr/lib/gcc/x86_64-redhat-linux/9/libgfortran.so
removes the problem, which now appears to me as a packaging problem on the side of RedHat.

thanks again,
Kay