On Saturday, January 27, 2018 at 4:45:35 PM UTC-5, FortranFan wrote:
> ..
>
> The original post finds:
> "gfortran trunk: 100% tests passed, 0 tests failed out of 1553" and
> ..
> Now consider a reduced test of that case with one modification to the CONTAINed function i.e., to use the RESULT keyword with the function. WHOOF, the test with gfortran fails!! ..
>
> So my point is one can read little into "% NN passed" reports, ..
So previously I pointed an issue with compilers regarding the test toward aliasing a function result with a host-associated variable.
Now consider the case in gfortran testsuite named, "alloc_comp_assign_1":
https://github.com/gcc-mirror/gcc/blob/master/gcc/testsuite/gfortran.dg/alloc_comp_assign_1.f90
My observation is this test itself has issues and requires review and validation.
See a reduced version of this case which shows gfortran compiler to fail the test:
--- begin console output using gfortran ---
C:\Temp>type p.f90
use, intrinsic :: iso_fortran_env, only : compiler_version
type :: t
character(len=1), allocatable :: c(:)
end type
type(t) :: x(3)
type(t) :: y(3)
print *, "Compiler Version: ", compiler_version()
x(1)%c = [ "h","e","l","l","o" ]
x(2)%c = [ "g","'","d","a","y" ]
x(3)%c = [ "g","o","d","a","g" ]
y(2:1:-1) = x(1:2)
print *, "x(1)%c = ", x(1)%c, "; expected = ", [ "h","e","l","l","o" ]
print *, "y(1)%c = ", y(1)%c, "; expected = ", [ "h","e","l","l","o" ]
if (any (y(1)%c /= [ "h","e","l","l","o" ]) ) then
print *, "Test failed."
else
print *, "Successful test."
end if
stop
end
C:\Temp>gfortran p.f90 -o p.exe
C:\Temp>p.exe
Compiler Version: GCC version 8.0.0 20171217 (experimental)
x(1)%c = hello; expected = hello
y(1)%c = g'day; expected = hello
Test failed.
C:\Temp>
--- end console output ---
whereas it passes with Intel Fortran compiler:
--- begin console output with Intel Fortran ---
C:\Temp>type p.f90
use, intrinsic :: iso_fortran_env, only : compiler_version
type :: t
character(len=1), allocatable :: c(:)
end type
type(t) :: x(3)
type(t) :: y(3)
print *, "Compiler Version: ", compiler_version()
x(1)%c = [ "h","e","l","l","o" ]
x(2)%c = [ "g","'","d","a","y" ]
x(3)%c = [ "g","o","d","a","g" ]
y(2:1:-1) = x(1:2)
print *, "x(1)%c = ", x(1)%c, "; expected = ", [ "h","e","l","l","o" ]
print *, "y(1)%c = ", y(1)%c, "; expected = ", [ "h","e","l","l","o" ]
if (any (y(1)%c /= [ "h","e","l","l","o" ]) ) then
print *, "Test failed."
else
print *, "Successful test."
end if
stop
end
C:\Temp>ifort /standard-semantics /warn:all /check:all p.f90 -o p.exe
Intel(R) Visual Fortran Intel(R) 64 Compiler for applications running on Intel(R
) 64, Version 18.0.1.156 Build 20171018
Copyright (C) 1985-2017 Intel Corporation. All rights reserved.
Microsoft (R) Incremental Linker Version 14.12.25835.0
Copyright (C) Microsoft Corporation. All rights reserved.
-out:p.exe
-subsystem:console
p.obj
C:\Temp>p.exe
Compiler Version:
Intel(R) Visual Fortran Intel(R) 64 Compiler for applications running on Intel(
R) 64, Version 18.0.1.156 Build 20171018
x(1)%c = hello; expected = hello
y(1)%c = hello; expected = hello
Successful test.
C:\Temp>
--- end console output ---
So as far as "alloc_comp_assign_1" is concerned, the situation is opposite to what is indicated in the original post.
Again, I think what the Fortran ecosystem can benefit from is a test suite that is thoroughly validated and in my opinion one that is also standardized.