Skip to content

Commit eb08ec9

Browse files
committed
test: add cast-on-write to see if GCC 9 bug triggers segfaul
1 parent 0c9a03d commit eb08ec9

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

test/test_cast.f90

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ subroutine test_cast_write(fn)
2626

2727
type(hdf5_file) :: h
2828

29+
real(real64) :: darr(2) = 12._real64
30+
2931
call h%open(fn, action='w')
3032

3133
!> test values
@@ -36,6 +38,7 @@ subroutine test_cast_write(fn)
3638
call h%write('/1d_real32', [1._real32, 32._real32])
3739
call h%write('/1d_int32', [2_int32, 4_int32])
3840
call h%write('/char', "hello")
41+
call h%write('/cast/r64tor32', real(darr))
3942

4043
call h%close()
4144

@@ -61,6 +64,7 @@ subroutine test_cast_read(fn)
6164
if (h%class("/scalar_real32") /= H5T_FLOAT_F) error stop "real32 not float"
6265
if (h%class("/scalar_real64") /= H5T_FLOAT_F) error stop "real64 not float"
6366
if (h%class("/char") /= H5T_STRING_F) error stop "char not string"
67+
if (h%class('/cast/r64tor32') /= H5T_FLOAT_F) error stop "cast not float"
6468
print *, "OK: class method"
6569

6670
!> %dtype method
@@ -69,6 +73,7 @@ subroutine test_cast_read(fn)
6973
if (h%dtype("/scalar_real32") /= H5T_NATIVE_REAL) error stop "real32 type"
7074
if (h%dtype("/scalar_real64") /= H5T_NATIVE_DOUBLE) error stop "real64 type"
7175
if (h%dtype("/char") /= H5T_NATIVE_CHARACTER) error stop "char type"
76+
if (h%dtype('/cast/r64tor32') /= H5T_NATIVE_REAL) error stop "cast type"
7277
print *, "OK: dtype method"
7378

7479
!> read casting -- real32 to real64 and int32 to int64

0 commit comments

Comments
 (0)