On Tue, Jan 23, 2018 at 6:33 PM, Thomas Koenig <tkoe...@netcologne.de> wrote: > Hi Janne, > >> When associating a variable of type character, if the length of the >> target isn't known, set it to zero rather than leaving it unset. This >> is not a complete fix for making associate of characters work >> properly, but papers over an ICE in the middle-end. See PR 83344 for >> more details. >> >> Regtested on x86_64-pc-linux-gnu, Ok for trunk? > > > Does the code which is accepted then execute correctly?
Hmm, prompted by your question I did some investigating, and I present to you evidence of GFortran being a quantum mechanical compiler (spooky action at a distance!): Consider the slightly fleshed out testcase from PR 83975: program foo call s("foo") contains subroutine s(x) character(*) :: x print *, "X:", x, ":ENDX" print *, "len(x): ", len(x) ! associate (y => x) ! print *, "Y:", y, ":ENDY" ! print *, "len(y): ", len(y) ! end associate end subroutine s end program foo With the associate stuff commented out, it's fairly bog-standard stuff, and the output is the expected: X:foo:ENDX len(x): 3 Now, incorporating the commented out associate block, and the result is: X::ENDX len(x): 0 Y::ENDY len(y): 0 So the associate construct manages to somehow break the variable X in the outer scope! -- Janne Blomqvist