public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/36526] New: pointer in pure function
@ 2008-06-13 12:58 aradi at bccms dot uni-bremen dot de
2008-06-13 17:53 ` [Bug fortran/36526] " burnus at gcc dot gnu dot org
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: aradi at bccms dot uni-bremen dot de @ 2008-06-13 12:58 UTC (permalink / raw)
To: gcc-bugs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1584 bytes --]
Hi,
I discovered a problem with gfortran 4.3.1 when compiling code with pure
function with pointer argument. Inside the pure function, the argument is
passed further to an other function. This seems to work, as long this other
function is an intrinsic function, but seems to fail for user defined pure
functions. The effect is demonstrated by the code below.
Best regards,
Bálint
--------------------------------------------------------
module TestPure
implicit none
type T1
character(10) :: str
end type T1
contains
pure function getT1Len(self) result(t1len)
type(T1), pointer :: self
integer :: t1len
t1len = getStrLen(self%str)
!t1len = len_trim(self%str) ! <- this would work
end function getT1Len
pure function getStrLen(str) result(length)
character(*), intent(in) :: str
integer :: length
length = len_trim(str)
end function getStrLen
end module TestPure
program Test
use TestPure
implicit none
type(T1), pointer :: pT1
allocate(pT1)
pT1%str = "test"
write (*,*) getT1Len(pT1)
deallocate(pT1)
end program Test
------------------------------------------------------
--
Summary: pointer in pure function
Product: gcc
Version: 4.3.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: aradi at bccms dot uni-bremen dot de
GCC target triplet: x86_64-unknown-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36526
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/36526] pointer in pure function
2008-06-13 12:58 [Bug fortran/36526] New: pointer in pure function aradi at bccms dot uni-bremen dot de
@ 2008-06-13 17:53 ` burnus at gcc dot gnu dot org
2008-06-20 10:44 ` pault at gcc dot gnu dot org
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: burnus at gcc dot gnu dot org @ 2008-06-13 17:53 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from burnus at gcc dot gnu dot org 2008-06-13 17:52 -------
CONFIRM. Works with other compilers. The constraint checked for is:
"C1272 In a pure subprogram any designator with a base object that is in common
or accessed by host or use association, is a dummy argument of a pure function,
is a dummy argument with INTENT (IN) of a pure subroutine, or an object that is
storage associated with any such variable, shall not be used in the following
contexts: [...]
(5) As an actual argument associated with a dummy argument with INTENT (OUT) or
INTENT (INOUT) or with the POINTER attribute." (From F2003.)
At a glance, it seems as if this applies, but as the non-normative note
indicates, C1272 does not apply in this case:
"NOTE 12.45 Pure subroutines are included to allow subroutine calls from pure
procedures in a safe way [...] The constraints for pure subroutines are
based on the same principles as for pure functions, except that side effects to
INTENT (OUT), INTENT (INOUT), and pointer dummy arguments are permitted."
However, I failed to find this in the normative part; I will try a bit more to
figure out why C1272 does not apply.
--
burnus at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Keywords| |rejects-valid
Last reconfirmed|0000-00-00 00:00:00 |2008-06-13 17:52:34
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36526
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/36526] pointer in pure function
2008-06-13 12:58 [Bug fortran/36526] New: pointer in pure function aradi at bccms dot uni-bremen dot de
2008-06-13 17:53 ` [Bug fortran/36526] " burnus at gcc dot gnu dot org
@ 2008-06-20 10:44 ` pault at gcc dot gnu dot org
2008-06-25 23:06 ` pault at gcc dot gnu dot org
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: pault at gcc dot gnu dot org @ 2008-06-20 10:44 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from pault at gcc dot gnu dot org 2008-06-20 10:43 -------
(In reply to comment #1)
This is due to an error in interface.c. The following fixes the fault,
bootstraps and regtests OK. I will apply as obvious just as soon as I can.
Paul
Index: gcc/fortran/interface.c
===================================================================
*** gcc/fortran/interface.c (revision 136870)
--- gcc/fortran/interface.c (working copy)
*************** check_intents (gfc_formal_arglist *f, gf
*** 2379,2385 ****
return FAILURE;
}
! if (a->expr->symtree->n.sym->attr.pointer)
{
gfc_error ("Procedure argument at %L is local to a PURE "
"procedure and has the POINTER attribute",
--- 2379,2385 ----
return FAILURE;
}
! if (f->sym->attr.pointer)
{
gfc_error ("Procedure argument at %L is local to a PURE "
"procedure and has the POINTER attribute",
--
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|NEW |ASSIGNED
Last reconfirmed|2008-06-13 17:52:34 |2008-06-20 10:43:30
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36526
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/36526] pointer in pure function
2008-06-13 12:58 [Bug fortran/36526] New: pointer in pure function aradi at bccms dot uni-bremen dot de
2008-06-13 17:53 ` [Bug fortran/36526] " burnus at gcc dot gnu dot org
2008-06-20 10:44 ` pault at gcc dot gnu dot org
@ 2008-06-25 23:06 ` pault at gcc dot gnu dot org
2008-08-08 22:24 ` jv244 at cam dot ac dot uk
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: pault at gcc dot gnu dot org @ 2008-06-25 23:06 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from pault at gcc dot gnu dot org 2008-06-25 23:05 -------
Subject: Bug 36526
Author: pault
Date: Wed Jun 25 23:04:33 2008
New Revision: 137125
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=137125
Log:
2008-06-25 Paul Thomas <pault@gcc.gnu.org>
PR fortran/36526
* interface.c (check_intents): Correct error where the actual
arg was checked for a pointer argument, rather than the formal.
2008-06-25 Paul Thomas <pault@gcc.gnu.org>
PR fortran/36526
* gfortran.dg/proc_formal_proc_2.f90: New test.
Added:
trunk/gcc/testsuite/gfortran.dg/pure_formal_proc_2.f90
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36526
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/36526] pointer in pure function
2008-06-13 12:58 [Bug fortran/36526] New: pointer in pure function aradi at bccms dot uni-bremen dot de
` (2 preceding siblings ...)
2008-06-25 23:06 ` pault at gcc dot gnu dot org
@ 2008-08-08 22:24 ` jv244 at cam dot ac dot uk
2008-11-18 10:03 ` pault at gcc dot gnu dot org
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: jv244 at cam dot ac dot uk @ 2008-08-08 22:24 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from jv244 at cam dot ac dot uk 2008-08-08 22:23 -------
this bug seems fixed in 4.4.0, should it be closed?
--
jv244 at cam dot ac dot uk changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to work| |4.4.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36526
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/36526] pointer in pure function
2008-06-13 12:58 [Bug fortran/36526] New: pointer in pure function aradi at bccms dot uni-bremen dot de
` (3 preceding siblings ...)
2008-08-08 22:24 ` jv244 at cam dot ac dot uk
@ 2008-11-18 10:03 ` pault at gcc dot gnu dot org
2008-11-27 22:23 ` pault at gcc dot gnu dot org
2008-11-27 22:24 ` pault at gcc dot gnu dot org
6 siblings, 0 replies; 8+ messages in thread
From: pault at gcc dot gnu dot org @ 2008-11-18 10:03 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from pault at gcc dot gnu dot org 2008-11-18 10:01 -------
(In reply to comment #4)
> this bug seems fixed in 4.4.0, should it be closed?
>
Joost,
I forgot the PR and missed your prompt - I'll apply it to 4.3 and close it.
Thanks
Paul
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36526
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/36526] pointer in pure function
2008-06-13 12:58 [Bug fortran/36526] New: pointer in pure function aradi at bccms dot uni-bremen dot de
` (4 preceding siblings ...)
2008-11-18 10:03 ` pault at gcc dot gnu dot org
@ 2008-11-27 22:23 ` pault at gcc dot gnu dot org
2008-11-27 22:24 ` pault at gcc dot gnu dot org
6 siblings, 0 replies; 8+ messages in thread
From: pault at gcc dot gnu dot org @ 2008-11-27 22:23 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from pault at gcc dot gnu dot org 2008-11-27 22:21 -------
Subject: Bug 36526
Author: pault
Date: Thu Nov 27 22:20:27 2008
New Revision: 142248
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=142248
Log:
2008-11-27 Paul Thomas <pault@gcc.gnu.org>
PR fortran/36526
* interface.c (check_intents): Correct error where the actual
arg was checked for a pointer argument, rather than the formal.
2008-11-27 Paul Thomas <pault@gcc.gnu.org>
PR fortran/36526
* gfortran.dg/pure_formal_proc_2.f90: New test.
Added:
branches/gcc-4_3-branch/gcc/testsuite/gfortran.dg/pure_formal_proc_2.f90
Modified:
branches/gcc-4_3-branch/gcc/fortran/ChangeLog
branches/gcc-4_3-branch/gcc/fortran/interface.c
branches/gcc-4_3-branch/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36526
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/36526] pointer in pure function
2008-06-13 12:58 [Bug fortran/36526] New: pointer in pure function aradi at bccms dot uni-bremen dot de
` (5 preceding siblings ...)
2008-11-27 22:23 ` pault at gcc dot gnu dot org
@ 2008-11-27 22:24 ` pault at gcc dot gnu dot org
6 siblings, 0 replies; 8+ messages in thread
From: pault at gcc dot gnu dot org @ 2008-11-27 22:24 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from pault at gcc dot gnu dot org 2008-11-27 22:23 -------
Fixed on trunk and 4.3.
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=36526
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2008-11-27 22:24 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-06-13 12:58 [Bug fortran/36526] New: pointer in pure function aradi at bccms dot uni-bremen dot de
2008-06-13 17:53 ` [Bug fortran/36526] " burnus at gcc dot gnu dot org
2008-06-20 10:44 ` pault at gcc dot gnu dot org
2008-06-25 23:06 ` pault at gcc dot gnu dot org
2008-08-08 22:24 ` jv244 at cam dot ac dot uk
2008-11-18 10:03 ` pault at gcc dot gnu dot org
2008-11-27 22:23 ` pault at gcc dot gnu dot org
2008-11-27 22:24 ` 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).