public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/36528]  New: Cray pointer to function mishandled
@ 2008-06-13 14:30 burnus at gcc dot gnu dot org
  2008-06-13 16:55 ` [Bug fortran/36528] " burnus at gcc dot gnu dot org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: burnus at gcc dot gnu dot org @ 2008-06-13 14:30 UTC (permalink / raw)
  To: gcc-bugs

http://groups.google.com/group/comp.lang.fortran/msg/86b65bad78e6af78

The following program should compile (with -fcray-pointer) and print on run
time:

 integral f(x) u intervalu [0,1] =  0.49975004
 integral f(x) u intervalu [0,1] =  0.49975004

sunf95 handles this correctly, however, gfortran fails at link time:

undefined reference to `fcn_'

     pointer (pfcn, fcn)
     pfcn = loc(p1) ! p1 is a function interface
        y = y + fcn(x)*dx ! Directly calling p1
     y = euler(0.0,1.0,0.0005,fcn)

The dump shows:
  integer(kind=8) pfcn;
    D.1063 = (integer(kind=8)) p1;
    pfcn = D.1063;
        y = <<< Unknown tree: call_expr
  4
  (real(kind=4) (*<T2ef>) (real(kind=4) &)) pfcn

  &x >>>
  (&x) * dx +y
    y = euler (&C.1072, &C.1073, &C.1074, fcn);

Full source code, see link. I think the test was created/tested for ifort and
gives there an ICE.


-- 
           Summary: Cray pointer to function mishandled
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Keywords: rejects-valid
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: burnus at gcc dot gnu dot org


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


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

* [Bug fortran/36528] Cray pointer to function mishandled
  2008-06-13 14:30 [Bug fortran/36528] New: Cray pointer to function mishandled burnus at gcc dot gnu dot org
@ 2008-06-13 16:55 ` burnus at gcc dot gnu dot org
  2009-02-11 15:09 ` pault at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: burnus at gcc dot gnu dot org @ 2008-06-13 16:55 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from burnus at gcc dot gnu dot org  2008-06-13 16:54 -------
For gfortran documentation, see:
http://gcc.gnu.org/onlinedocs/gfortran/Cray-pointers.html#Cray-pointers

a) If used directly, the tree is wrong (see dump), but it works nonetheless
   (I somehow have not to realize this)

b) If used as actual argument, it is completely mishandled. Without explicit
interface, it should be:
   myfunc( (void)(*<T4>)(void) pointee)
(i.e. "build_pointer_type (build_function_type (void_type_node, NULL_TREE))")
and with an explicit interface, it should convert pointee to the tree TYPE of
the dummy argument.)

c) TODO: Check whether using the pointee as non-procedure actual argument works
(incl. VALUE attribute and similar things; it probably works.)


-- 


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


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

* [Bug fortran/36528] Cray pointer to function mishandled
  2008-06-13 14:30 [Bug fortran/36528] New: Cray pointer to function mishandled burnus at gcc dot gnu dot org
  2008-06-13 16:55 ` [Bug fortran/36528] " burnus at gcc dot gnu dot org
@ 2009-02-11 15:09 ` pault at gcc dot gnu dot org
  2009-02-13 21:13 ` pault at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pault at gcc dot gnu dot org @ 2009-02-11 15:09 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pault at gcc dot gnu dot org  2009-02-11 15:08 -------
This fixes the bug.  I need to look at the passing of Cray pointers in general
because it looks a bit shakey to me.

trans-expr.c:

2626c2626,2637
<             if (fsym && fsym->attr.value)
---
> 	      if (fsym && fsym->attr.flavor == FL_PROCEDURE
> 		    && e->expr_type == EXPR_VARIABLE
> 		    && e->symtree->n.sym->attr.cray_pointee)
> 		{
> 		    /* The Cray pointer needs to be converted to a pointer type
> 		       pointee.  The symbol gives the pointee address.  */
> 		    gfc_conv_expr (&parmse, e);
> 		    type = build_pointer_type (TREE_TYPE (parmse.expr));
> 		    tmp = gfc_get_symbol_decl (e->symtree->n.sym->cp_pointer);
> 		    parmse.expr = convert (type, tmp);
> 		}
> 	      else if (fsym && fsym->attr.value)

Cheers

Paul


-- 

pault at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |pault at gcc dot gnu dot org
                   |dot org                     |
             Status|UNCONFIRMED                 |ASSIGNED
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2009-02-11 15:08:51
               date|                            |


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


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

* [Bug fortran/36528] Cray pointer to function mishandled
  2008-06-13 14:30 [Bug fortran/36528] New: Cray pointer to function mishandled burnus at gcc dot gnu dot org
  2008-06-13 16:55 ` [Bug fortran/36528] " burnus at gcc dot gnu dot org
  2009-02-11 15:09 ` pault at gcc dot gnu dot org
@ 2009-02-13 21:13 ` pault at gcc dot gnu dot org
  2009-03-28 17:09 ` pault at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pault at gcc dot gnu dot org @ 2009-02-13 21:13 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from pault at gcc dot gnu dot org  2009-02-13 21:12 -------
Subject: Bug 36528

Author: pault
Date: Fri Feb 13 21:12:34 2009
New Revision: 144164

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=144164
Log:
2009-02-13  Paul Thomas  <pault@gcc.gnu.org>

        PR fortran/36703
        PR fortran/36528
        * trans-expr.c (gfc_conv_function_val): Stabilize Cray-pointer
        function references to ensure that a valid expression is used.
        (gfc_conv_function_call): Pass Cray pointers to procedures.

2009-02-13  Paul Thomas  <pault@gcc.gnu.org>

        PR fortran/36528
        * gfortran.dg/cray_pointers_8.f90: New test.

        PR fortran/36703
        * gfortran.dg/cray_pointers_9.f90: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/cray_pointers_8.f90
    trunk/gcc/testsuite/gfortran.dg/cray_pointers_9.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/trans-expr.c
    trunk/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug fortran/36528] Cray pointer to function mishandled
  2008-06-13 14:30 [Bug fortran/36528] New: Cray pointer to function mishandled burnus at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2009-02-13 21:13 ` pault at gcc dot gnu dot org
@ 2009-03-28 17:09 ` pault at gcc dot gnu dot org
  2009-03-28 17:39 ` pault at gcc dot gnu dot org
  2009-04-06 11:07 ` pault at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: pault at gcc dot gnu dot org @ 2009-03-28 17:09 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from pault at gcc dot gnu dot org  2009-03-28 17:08 -------
Subject: Bug 36528

Author: pault
Date: Sat Mar 28 17:08:25 2009
New Revision: 145196

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=145196
Log:
2009-02-13  Paul Thomas  <pault@gcc.gnu.org>

        PR fortran/36703
        PR fortran/36528
        * trans-expr.c (gfc_conv_function_val): Stabilize Cray-pointer
        function references to ensure that a valid expression is used.
        (gfc_conv_function_call): Pass Cray pointers to procedures.

2009-02-13  Paul Thomas  <pault@gcc.gnu.org>

        PR fortran/36528
        * gfortran.dg/cray_pointers_8.f90: New test.

        PR fortran/36703
        * gfortran.dg/cray_pointers_9.f90: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/char_result_13.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/trans-array.c
    trunk/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug fortran/36528] Cray pointer to function mishandled
  2008-06-13 14:30 [Bug fortran/36528] New: Cray pointer to function mishandled burnus at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2009-03-28 17:09 ` pault at gcc dot gnu dot org
@ 2009-03-28 17:39 ` pault at gcc dot gnu dot org
  2009-04-06 11:07 ` pault at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: pault at gcc dot gnu dot org @ 2009-03-28 17:39 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from pault at gcc dot gnu dot org  2009-03-28 17:39 -------
(In reply to comment #4)

Not so - this was the wrong message for another commit.  This fix is on the
way.

Paul


-- 


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


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

* [Bug fortran/36528] Cray pointer to function mishandled
  2008-06-13 14:30 [Bug fortran/36528] New: Cray pointer to function mishandled burnus at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2009-03-28 17:39 ` pault at gcc dot gnu dot org
@ 2009-04-06 11:07 ` pault at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: pault at gcc dot gnu dot org @ 2009-04-06 11:07 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from pault at gcc dot gnu dot org  2009-04-06 11:07 -------
Fixed on trunk and 4.4

Thanks for the report

Paul


-- 

pault at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


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


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

end of thread, other threads:[~2009-04-06 11:07 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-06-13 14:30 [Bug fortran/36528] New: Cray pointer to function mishandled burnus at gcc dot gnu dot org
2008-06-13 16:55 ` [Bug fortran/36528] " burnus at gcc dot gnu dot org
2009-02-11 15:09 ` pault at gcc dot gnu dot org
2009-02-13 21:13 ` pault at gcc dot gnu dot org
2009-03-28 17:09 ` pault at gcc dot gnu dot org
2009-03-28 17:39 ` pault at gcc dot gnu dot org
2009-04-06 11:07 ` pault at gcc dot gnu dot 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).