2017-12-08 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gfortran.dg / transfer_simplify_8.f90
blob75b084670ac6ab9a26bb47fc55910940999fd8c9
1 ! { dg-do run }
2 ! { dg-options "-O0" }
3 ! PR fortran/34537
4 ! simplify_transfer used to ICE on divide by zero for cases like this,
5 ! where the mold expression is a non-constant character expression.
7 ! Testcase contributed by Tobias Burnus <burnus@gcc.gnu.org >
9 character, pointer :: ptr(:)
10 character(8) :: a
11 allocate(ptr(9))
12 ptr = transfer('Sample#0'//achar(0),ptr) ! Causes ICE
13 if (any (ptr .ne. ['S','a','m','p','l','e','#','0',achar(0)])) call abort
14 call test(a)
15 if (a .ne. 'Sample#2') call abort
16 contains
17 subroutine test(a)
18 character(len=*) :: a
19 a = transfer('Sample#2',a)
20 end subroutine test
21 end