https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93148
Bug ID: 93148 Summary: Pointer-function-result as LVALUE variable – function called multiple times with copy-in/out Product: gcc Version: 10.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: burnus at gcc dot gnu.org CC: tkoenig at gcc dot gnu.org Target Milestone: --- Created attachment 47588 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=47588&action=edit Test case – compile & run Found when looking at PR91640, cf. https://gcc.gnu.org/ml/gcc-patches/2020-01/threads.html#00070 If one uses: call foo(f()) where foo takes a nonpointer dummy argument and f returns a pointer, the pointer result is regarded as normal variable. (= gfc_is_variable == true). Unfortunately, "f()" is called twice: once for the copy in and once for the copy out. Expected: It is only called once. See attached test case.