public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/58002] New: [IR tracking] Pointer function results in non pointer context: Shall use a temporary
@ 2013-07-27 11:22 burnus at gcc dot gnu.org
  2015-10-13 12:59 ` [Bug fortran/58002] " dominiq at lps dot ens.fr
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: burnus at gcc dot gnu.org @ 2013-07-27 11:22 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58002

            Bug ID: 58002
           Summary: [IR tracking] Pointer function results in non pointer
                    context: Shall use a temporary
           Product: gcc
           Version: 4.9.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

If "fx()" is a pointer returning function, "fx()" is an expression. Hence, for
   call foo(fx())
the argument should be not the pointer address of fx() but a temporary with the
value of the function result.

Everything becomes messier with Fortran 2008 as calls to pointer-returning
functions count as variables.

gfortran currently does not create a temporary in line with Fortran 2008 (!),
but it should to conform to Fortran 90/95/2003.

See Interpretation Request F08/0089 at
http://www.j3-fortran.org/doc/year/13/13-006Ar1.txt - but also at the
discussion at http://mailman.j3-fortran.org/pipermail/j3/2013-July/006578.html


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug fortran/58002] [IR tracking] Pointer function results in non pointer context: Shall use a temporary
  2013-07-27 11:22 [Bug fortran/58002] New: [IR tracking] Pointer function results in non pointer context: Shall use a temporary burnus at gcc dot gnu.org
@ 2015-10-13 12:59 ` dominiq at lps dot ens.fr
  2015-10-13 13:24 ` dominiq at lps dot ens.fr
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: dominiq at lps dot ens.fr @ 2015-10-13 12:59 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58002

--- Comment #1 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
The test

   Module m200c2
     Integer,Target :: x = 42
   Contains
     Function fx()
       Integer,Pointer :: fx
       fx => x
     End Function
   End Module

   Program q1
     Use m200c2
     Call test(x,fx())                  ! The call.
   Contains
     Subroutine test(a,b)
       Integer :: a,b
       a = a*10                         ! The assignment.
       Print *,a,b
     End Subroutine
   End Program

outputs 

         420         420

Am I correct to understand that this answer is OK for Fortran 2008, but should
be

         420         42

for Fortran 2003 and older?

Note that if I replace the line

     Call test(x,fx())                  ! The call.

with

     Call test(x,(fx()))                  ! The call.

I get the later answer.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug fortran/58002] [IR tracking] Pointer function results in non pointer context: Shall use a temporary
  2013-07-27 11:22 [Bug fortran/58002] New: [IR tracking] Pointer function results in non pointer context: Shall use a temporary burnus at gcc dot gnu.org
  2015-10-13 12:59 ` [Bug fortran/58002] " dominiq at lps dot ens.fr
@ 2015-10-13 13:24 ` dominiq at lps dot ens.fr
  2021-12-18  3:23 ` pinskia at gcc dot gnu.org
  2021-12-18  3:23 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: dominiq at lps dot ens.fr @ 2015-10-13 13:24 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58002

Dominique d'Humieres <dominiq at lps dot ens.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING
   Last reconfirmed|                            |2015-10-13
     Ever confirmed|0                           |1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug fortran/58002] [IR tracking] Pointer function results in non pointer context: Shall use a temporary
  2013-07-27 11:22 [Bug fortran/58002] New: [IR tracking] Pointer function results in non pointer context: Shall use a temporary burnus at gcc dot gnu.org
  2015-10-13 12:59 ` [Bug fortran/58002] " dominiq at lps dot ens.fr
  2015-10-13 13:24 ` dominiq at lps dot ens.fr
@ 2021-12-18  3:23 ` pinskia at gcc dot gnu.org
  2021-12-18  3:23 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-18  3:23 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58002

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Ifort also produces:

         420         420

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug fortran/58002] [IR tracking] Pointer function results in non pointer context: Shall use a temporary
  2013-07-27 11:22 [Bug fortran/58002] New: [IR tracking] Pointer function results in non pointer context: Shall use a temporary burnus at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2021-12-18  3:23 ` pinskia at gcc dot gnu.org
@ 2021-12-18  3:23 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-18  3:23 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58002

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #2)
> Ifort also produces:
> 
>          420         420

I should say using -stand f03 and -stand f95.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-12-18  3:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-27 11:22 [Bug fortran/58002] New: [IR tracking] Pointer function results in non pointer context: Shall use a temporary burnus at gcc dot gnu.org
2015-10-13 12:59 ` [Bug fortran/58002] " dominiq at lps dot ens.fr
2015-10-13 13:24 ` dominiq at lps dot ens.fr
2021-12-18  3:23 ` pinskia at gcc dot gnu.org
2021-12-18  3:23 ` pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).