PR c++/27177
[official-gcc.git] / gcc / testsuite / gfortran.dg / char_result_12.f90
blob6612dcf888fa5e94351cbf7a2d9bc72152431816
1 ! { dg-do run }
2 ! Tests the fix for PR29912, in which the call to JETTER
3 ! would cause a segfault because a temporary was not being written.
5 ! Contributed by Philip Mason <pmason@ricardo.com>
7 program testat
8 character(len=4) :: ctemp(2)
9 character(len=512) :: temper(2)
11 !------------------------
12 !'This was OK.'
13 !------------------------
14 temper(1) = 'doncaster'
15 temper(2) = 'uxbridge'
16 ctemp = temper
17 if (any (ctemp /= ["donc", "uxbr"])) call abort ()
19 !------------------------
20 !'This went a bit wrong.'
21 !------------------------
22 ctemp = jetter(1,2)
23 if (any (ctemp /= ["donc", "uxbr"])) call abort ()
25 contains
26 function jetter(id1,id2)
27 character(len=512) :: jetter(id1:id2)
28 jetter(id1) = 'doncaster'
29 jetter(id2) = 'uxbridge'
30 end function jetter
31 end program testat