gfortran 8.3.1 fails any_matrix_type test
nncarlson opened this issue · comments
I'm testing the current version of gcc 8 (8.3.1-20190406) and test_any_matrix_type
is throwing this runtime error:
$ ./test_any_matrix_type
At line 464 of file /opt/src/petaca/petaca/test/parameter_list_type/test_any_matrix_type.F90
Fortran runtime error: Array bound mismatch for dimension 1 of array '<<unknown>>' (2/1)
Error termination. Backtrace:
#0 0x7f03ff61af9a in ???
#1 0x7f03ff61bb85 in ???
#2 0x7f03ff61bf57 in ???
#3 0x404495 in test_assignment
at /opt/src/petaca/petaca/test/parameter_list_type/test_any_matrix_type.F90:464
#4 0x400e02 in test_any_matrix_type
at /opt/src/petaca/petaca/test/parameter_list_type/test_any_matrix_type.F90:41
#5 0x41492f in main
at /opt/src/petaca/petaca/test/parameter_list_type/test_any_matrix_type.F90:27
I haven't investigated further, but I suspect a compiler bug. Earlier versions have been broken.
This is with "-fcheck=all -Wall -Wextra", which cmake uses for the Debug build type. No error with Release build type.
The following program demonstrates the issue, when compiled with gfortran -g -fcheck=all -Wall -Wextra junk.F90
. Interestingly, changing the reshaped shape to shape=[2,1]
, makes the error go away. As it stands, I don't think this is a major problem, since the Release build test passes (and it would fail if the assignment were getting truly messed up).
module junk
use, intrinsic :: iso_fortran_env
type, abstract, public :: parameter_entry
!! meta data associated with the parameter will go here
end type
type, extends(parameter_entry), public :: any_matrix
private
class(*), allocatable :: value(:,:)
contains
procedure :: set_value => set_matrix_value
generic :: get_value => get_matrix_int32
procedure, private :: get_matrix_int32
end type
interface any_matrix
procedure any_matrix_value
end interface
contains
function any_matrix_value (value) result (obj)
class(*), intent(in) :: value(:,:)
type(any_matrix) :: obj
call set_matrix_value (obj, value)
end function any_matrix_value
subroutine set_matrix_value (this, value)
class(any_matrix), intent(out) :: this
class(*), intent(in) :: value(:,:)
allocate(this%value(lbound(value,1):ubound(value,1),&
lbound(value,2):ubound(value,2)), source=value)
end subroutine set_matrix_value
!! Return a int32 kind integer value.
subroutine get_matrix_int32 (this, value, errc)
class(any_matrix), intent(in) :: this
integer(int32), allocatable :: value(:,:)
logical, intent(out) :: errc
select type (v => this%value)
type is (integer(int32))
value = v
errc = .false.
class default
errc = .true.
end select
end subroutine
end module
program stuff
use junk
type(any_matrix) :: x, y
call x%set_value (reshape([1,2],shape=[1,2]))
y = x
end program
The other thing I noticed is the slew of warning messages during compilation about variables possibly being used before defined, but they were compiler-generated variables, members of structs for array dope vectors, etc. That's not right at all.
Same problems for gfortran 9.1
@mattbement did you submit a bug report with your reproducer code? That seems small enough, and the problem large enough, that it should get some traction. Please let me know if you want/need help and ping me with a link to the bug tracker if you are able to get around to submitting it. If you don't have time let me know an I can do it.
Thanks!
@zbeekman - I've not submitted to gcc bugzilla before - so if you're willing, that would be great!
The other thing I noticed is the slew of warning messages during compilation about variables possibly being used before defined, but they were compiler-generated variables, members of structs for array dope vectors, etc. That's not right at all.
Yes this is very annoying. It would be a super useful warning if it weren't for all the false positives/errant output. I've taken to adding -Wno-maybe-undefined
I have 9.1.1 version and
Test project /home/term/Programs/petaca/petaca/build
Start 1: fortran_dynamic_loader
1/20 Test #1: fortran_dynamic_loader ........... Passed 0.04 sec
Start 2: map_any
2/20 Test #2: map_any .......................... Passed 0.01 sec
Start 3: any_scalar
3/20 Test #3: any_scalar ....................... Passed 0.00 sec
Start 4: any_vector
4/20 Test #4: any_vector ....................... Passed 0.00 sec
Start 5: any_matrix
5/20 Test #5: any_matrix ....................... Passed 0.01 sec
Start 6: parameter_list
6/20 Test #6: parameter_list ................... Passed 0.00 sec
Start 7: parameter_list_json
7/20 Test #7: parameter_list_json .............. Passed 0.00 sec
Start 8: state_history
8/20 Test #8: state_history .................... Passed 0.00 sec
Start 9: secure_hash
9/20 Test #9: secure_hash ...................... Passed 0.50 sec
Start 10: timer_tree
10/20 Test #10: timer_tree ....................... Passed 2.19 sec
Start 11: strip-file1
11/20 Test #11: strip-file1 ...................... Passed 0.01 sec
Start 12: json-ex1
12/20 Test #12: json-ex1 ......................... Passed 0.00 sec
Start 13: json-ex2
13/20 Test #13: json-ex2 ......................... Passed 0.00 sec
Start 14: json-ex3
14/20 Test #14: json-ex3 ......................... Passed 0.00 sec
Start 15: json-ex4
15/20 Test #15: json-ex4 ......................... Passed 0.00 sec
Start 16: json-ex5
16/20 Test #16: json-ex5 ......................... Passed 0.00 sec
Start 17: json-ex6
17/20 Test #17: json-ex6 ......................... Passed 0.00 sec
Start 18: json-ex7
18/20 Test #18: json-ex7 ......................... Passed 0.00 sec
Start 19: json-ex8
19/20 Test #19: json-ex8 ......................... Passed 0.00 sec
Start 20: json-ex9
20/20 Test #20: json-ex9 ......................... Passed 0.00 sec
100% tests passed, 0 tests failed out of 20
gfortran --version
GNU Fortran (SUSE Linux) 9.1.1 20190527 [gcc-9-branch revision 271644]
Forgive a dumb question - this is the debug build?
ok, you are right, I forgot to switch to debug :/
Test project /home/term/Programs/petaca/petaca/build
Start 1: fortran_dynamic_loader
1/20 Test #1: fortran_dynamic_loader ........... Passed 0.04 sec
Start 2: map_any
2/20 Test #2: map_any .......................... Passed 0.00 sec
Start 3: any_scalar
3/20 Test #3: any_scalar ....................... Passed 0.00 sec
Start 4: any_vector
4/20 Test #4: any_vector ....................... Passed 0.00 sec
Start 5: any_matrix
5/20 Test #5: any_matrix .......................***Failed 0.02 sec
Start 6: parameter_list
6/20 Test #6: parameter_list ...................***Failed 0.01 sec
Start 7: parameter_list_json
7/20 Test #7: parameter_list_json .............. Passed 0.00 sec
Start 8: state_history
8/20 Test #8: state_history .................... Passed 0.00 sec
Start 9: secure_hash
9/20 Test #9: secure_hash ...................... Passed 0.41 sec
Start 10: timer_tree
10/20 Test #10: timer_tree ....................... Passed 2.42 sec
Start 11: strip-file1
11/20 Test #11: strip-file1 ...................... Passed 0.06 sec
Start 12: json-ex1
12/20 Test #12: json-ex1 ......................... Passed 0.00 sec
Start 13: json-ex2
13/20 Test #13: json-ex2 ......................... Passed 0.00 sec
Start 14: json-ex3
14/20 Test #14: json-ex3 ......................... Passed 0.00 sec
Start 15: json-ex4
15/20 Test #15: json-ex4 ......................... Passed 0.00 sec
Start 16: json-ex5
16/20 Test #16: json-ex5 ......................... Passed 0.00 sec
Start 17: json-ex6
17/20 Test #17: json-ex6 ......................... Passed 0.00 sec
Start 18: json-ex7
18/20 Test #18: json-ex7 ......................... Passed 0.00 sec
Start 19: json-ex8
19/20 Test #19: json-ex8 ......................... Passed 0.00 sec
Start 20: json-ex9
20/20 Test #20: json-ex9 ......................... Passed 0.00 sec
90% tests passed, 2 tests failed out of 20