public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/19673] New: pointer function with RESULT specified returns pointer to "ptr" rather than "*ptr"
@ 2005-01-28 16:46 paulthomas2 at wanadoo dot fr
2005-03-03 22:00 ` [Bug fortran/19673] " tobi at gcc dot gnu dot org
` (9 more replies)
0 siblings, 10 replies; 11+ messages in thread
From: paulthomas2 at wanadoo dot fr @ 2005-01-28 16:46 UTC (permalink / raw)
To: gcc-bugs
This is a bug that is specific to functions where RESULT is specified in the
function statement(function foo). In this case, the pointer itself is
printed.
Where RESULT is not specified, functions return a pointer result
correctly(function bar). Here the value pointed too is printed.
$ cat return_pointer.f90
! Test the return of pointer
program ret_ptr
print *, foo (99) , " from function foo (arg) result (ptr)"
print *, bar (99) , " from function bar (arg)"
contains
function foo (arg) result(ptr)
integer :: arg
integer, pointer :: ptr
allocate (ptr)
ptr = arg
end function foo
function bar (arg)
integer :: arg
integer, pointer :: bar
allocate (bar)
bar = arg
end function bar
end program ret_ptr
$ ./a
168034328 from function foo (arg) result (ptr)
99 from function bar (arg)
--
Summary: pointer function with RESULT specified returns pointer
to "ptr" rather than "*ptr"
Product: gcc
Version: 4.0.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: fortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: paulthomas2 at wanadoo dot fr
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19673
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/19673] pointer function with RESULT specified returns pointer to "ptr" rather than "*ptr"
2005-01-28 16:46 [Bug fortran/19673] New: pointer function with RESULT specified returns pointer to "ptr" rather than "*ptr" paulthomas2 at wanadoo dot fr
@ 2005-03-03 22:00 ` tobi at gcc dot gnu dot org
2005-03-03 22:08 ` tobi at gcc dot gnu dot org
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: tobi at gcc dot gnu dot org @ 2005-03-03 22:00 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From tobi at gcc dot gnu dot org 2005-03-03 21:59 -------
This is weird. I just came across code (written by me) that should ensure the
right behavior here.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Last reconfirmed|0000-00-00 00:00:00 |2005-03-03 21:59:57
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19673
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/19673] pointer function with RESULT specified returns pointer to "ptr" rather than "*ptr"
2005-01-28 16:46 [Bug fortran/19673] New: pointer function with RESULT specified returns pointer to "ptr" rather than "*ptr" paulthomas2 at wanadoo dot fr
2005-03-03 22:00 ` [Bug fortran/19673] " tobi at gcc dot gnu dot org
@ 2005-03-03 22:08 ` tobi at gcc dot gnu dot org
2005-03-03 22:17 ` tobi at gcc dot gnu dot org
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: tobi at gcc dot gnu dot org @ 2005-03-03 22:08 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From tobi at gcc dot gnu dot org 2005-03-03 22:08 -------
Found the bug. Fixing.
--
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |tobi at gcc dot gnu dot org
|dot org |
Status|NEW |ASSIGNED
Last reconfirmed|2005-03-03 21:59:57 |2005-03-03 22:08:15
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19673
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/19673] pointer function with RESULT specified returns pointer to "ptr" rather than "*ptr"
2005-01-28 16:46 [Bug fortran/19673] New: pointer function with RESULT specified returns pointer to "ptr" rather than "*ptr" paulthomas2 at wanadoo dot fr
2005-03-03 22:00 ` [Bug fortran/19673] " tobi at gcc dot gnu dot org
2005-03-03 22:08 ` tobi at gcc dot gnu dot org
@ 2005-03-03 22:17 ` tobi at gcc dot gnu dot org
2005-03-03 22:44 ` paulthomas2 at wanadoo dot fr
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: tobi at gcc dot gnu dot org @ 2005-03-03 22:17 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From tobi at gcc dot gnu dot org 2005-03-03 22:17 -------
Hm, there seems to be some confusion between when to use sym and when
sym->result for a function. My fix won't make it worse, though.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19673
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/19673] pointer function with RESULT specified returns pointer to "ptr" rather than "*ptr"
2005-01-28 16:46 [Bug fortran/19673] New: pointer function with RESULT specified returns pointer to "ptr" rather than "*ptr" paulthomas2 at wanadoo dot fr
` (2 preceding siblings ...)
2005-03-03 22:17 ` tobi at gcc dot gnu dot org
@ 2005-03-03 22:44 ` paulthomas2 at wanadoo dot fr
2005-03-03 22:54 ` tobi at gcc dot gnu dot org
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: paulthomas2 at wanadoo dot fr @ 2005-03-03 22:44 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From paulthomas2 at wanadoo dot fr 2005-03-03 22:43 -------
Subject: Re: pointer function with RESULT specified returns pointer to "ptr" rather than "*ptr"
I have become convinced that graphical/diagrammatic rendering of some of the
structures that we are using would be quite helpful. I'll have a think
about how to do it - I have a notion that a tree structure with access
macros on the connections might be a good mnemonic; cf our exchange of a few
minutes ago.
Paul
----- Original Message -----
From: "tobi at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: <paulthomas2@wanadoo.fr>
Sent: Thursday, March 03, 2005 11:17 PM
Subject: [Bug fortran/19673] pointer function with RESULT specified returns
pointer to "ptr" rather than "*ptr"
>
> ------- Additional Comments From tobi at gcc dot gnu dot org 2005-03-03
> 22:17 -------
> Hm, there seems to be some confusion between when to use sym and when
> sym->result for a function. My fix won't make it worse, though.
>
> --
>
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19673
>
> ------- You are receiving this mail because: -------
> You reported the bug, or are watching the reporter.
>
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19673
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/19673] pointer function with RESULT specified returns pointer to "ptr" rather than "*ptr"
2005-01-28 16:46 [Bug fortran/19673] New: pointer function with RESULT specified returns pointer to "ptr" rather than "*ptr" paulthomas2 at wanadoo dot fr
` (3 preceding siblings ...)
2005-03-03 22:44 ` paulthomas2 at wanadoo dot fr
@ 2005-03-03 22:54 ` tobi at gcc dot gnu dot org
2005-03-03 23:24 ` paulthomas2 at wanadoo dot fr
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: tobi at gcc dot gnu dot org @ 2005-03-03 22:54 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From tobi at gcc dot gnu dot org 2005-03-03 22:54 -------
In this particular case (sym vs sym->result) the right thing IMO would be to
either *always* create a sym->result variable, which takes on all the functions
attributes, or to *always* copy the attributes of the result variable to the
function's symbol. This should happen once the function has been completely
resolved. I believe that the latter option could be more difficult for the
exact reasons that the standard requires the use of RESULT in certain cases.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19673
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/19673] pointer function with RESULT specified returns pointer to "ptr" rather than "*ptr"
2005-01-28 16:46 [Bug fortran/19673] New: pointer function with RESULT specified returns pointer to "ptr" rather than "*ptr" paulthomas2 at wanadoo dot fr
` (4 preceding siblings ...)
2005-03-03 22:54 ` tobi at gcc dot gnu dot org
@ 2005-03-03 23:24 ` paulthomas2 at wanadoo dot fr
2005-03-04 21:04 ` cvs-commit at gcc dot gnu dot org
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: paulthomas2 at wanadoo dot fr @ 2005-03-03 23:24 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From paulthomas2 at wanadoo dot fr 2005-03-03 23:24 -------
Subject: Re: pointer function with RESULT specified returns pointer to "ptr" rather than "*ptr"
Is this connected with functions that return character pointers being so
completely screwed up?
----- Original Message -----
From: "tobi at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: <paulthomas2@wanadoo.fr>
Sent: Thursday, March 03, 2005 11:54 PM
Subject: [Bug fortran/19673] pointer function with RESULT specified returns
pointer to "ptr" rather than "*ptr"
>
> ------- Additional Comments From tobi at gcc dot gnu dot org 2005-03-03
> 22:54 -------
> In this particular case (sym vs sym->result) the right thing IMO would be
> to
> either *always* create a sym->result variable, which takes on all the
> functions
> attributes, or to *always* copy the attributes of the result variable to
> the
> function's symbol. This should happen once the function has been
> completely
> resolved. I believe that the latter option could be more difficult for
> the
> exact reasons that the standard requires the use of RESULT in certain
> cases.
>
> --
>
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19673
>
> ------- You are receiving this mail because: -------
> You reported the bug, or are watching the reporter.
>
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19673
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/19673] pointer function with RESULT specified returns pointer to "ptr" rather than "*ptr"
2005-01-28 16:46 [Bug fortran/19673] New: pointer function with RESULT specified returns pointer to "ptr" rather than "*ptr" paulthomas2 at wanadoo dot fr
` (5 preceding siblings ...)
2005-03-03 23:24 ` paulthomas2 at wanadoo dot fr
@ 2005-03-04 21:04 ` cvs-commit at gcc dot gnu dot org
2005-03-04 22:21 ` cvs-commit at gcc dot gnu dot org
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-03-04 21:04 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From cvs-commit at gcc dot gnu dot org 2005-03-04 21:04 -------
Subject: Bug 19673
CVSROOT: /cvs/gcc
Module name: gcc
Changes by: tobi@gcc.gnu.org 2005-03-04 21:03:46
Modified files:
gcc/fortran : ChangeLog trans-expr.c
gcc/testsuite : ChangeLog
Added files:
gcc/testsuite/gfortran.dg: func_result_1.f90
Log message:
fortran/
PR fortran/19673
* trans-expr.c (gfc_conv_function_call): Correctly dereference
argument from a pointer function also if it has a result clause.
testsuite/
PR fortran/19673
* gfortran.dg/func_result_1.f90: New test.
Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/ChangeLog.diff?cvsroot=gcc&r1=1.342&r2=1.343
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/trans-expr.c.diff?cvsroot=gcc&r1=1.38&r2=1.39
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.5108&r2=1.5109
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gfortran.dg/func_result_1.f90.diff?cvsroot=gcc&r1=NONE&r2=1.1
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19673
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/19673] pointer function with RESULT specified returns pointer to "ptr" rather than "*ptr"
2005-01-28 16:46 [Bug fortran/19673] New: pointer function with RESULT specified returns pointer to "ptr" rather than "*ptr" paulthomas2 at wanadoo dot fr
` (6 preceding siblings ...)
2005-03-04 21:04 ` cvs-commit at gcc dot gnu dot org
@ 2005-03-04 22:21 ` cvs-commit at gcc dot gnu dot org
2005-03-04 22:29 ` tobi at gcc dot gnu dot org
2005-03-04 22:39 ` tobi at gcc dot gnu dot org
9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-03-04 22:21 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From cvs-commit at gcc dot gnu dot org 2005-03-04 22:21 -------
Subject: Bug 19673
CVSROOT: /cvs/gcc
Module name: gcc
Branch: gcc-4_0-branch
Changes by: tobi@gcc.gnu.org 2005-03-04 22:21:17
Modified files:
gcc/fortran : ChangeLog trans-expr.c
gcc/testsuite : ChangeLog
Added files:
gcc/testsuite/gfortran.dg: func_result_1.f90
Log message:
fortran/
PR fortran/19673
* trans-expr.c (gfc_conv_function_call): Correctly dereference
argument from a pointer function also if it has a result clause.
testsuite/
PR fortran/19673
* gfortran.dg/func_result_1.f90: New test.
Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.335.2.6&r2=1.335.2.7
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/trans-expr.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.38&r2=1.38.2.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.5084.2.15&r2=1.5084.2.16
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gfortran.dg/func_result_1.f90.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.2.1
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19673
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/19673] pointer function with RESULT specified returns pointer to "ptr" rather than "*ptr"
2005-01-28 16:46 [Bug fortran/19673] New: pointer function with RESULT specified returns pointer to "ptr" rather than "*ptr" paulthomas2 at wanadoo dot fr
` (7 preceding siblings ...)
2005-03-04 22:21 ` cvs-commit at gcc dot gnu dot org
@ 2005-03-04 22:29 ` tobi at gcc dot gnu dot org
2005-03-04 22:39 ` tobi at gcc dot gnu dot org
9 siblings, 0 replies; 11+ messages in thread
From: tobi at gcc dot gnu dot org @ 2005-03-04 22:29 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From tobi at gcc dot gnu dot org 2005-03-04 22:29 -------
Fixed.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19673
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/19673] pointer function with RESULT specified returns pointer to "ptr" rather than "*ptr"
2005-01-28 16:46 [Bug fortran/19673] New: pointer function with RESULT specified returns pointer to "ptr" rather than "*ptr" paulthomas2 at wanadoo dot fr
` (8 preceding siblings ...)
2005-03-04 22:29 ` tobi at gcc dot gnu dot org
@ 2005-03-04 22:39 ` tobi at gcc dot gnu dot org
9 siblings, 0 replies; 11+ messages in thread
From: tobi at gcc dot gnu dot org @ 2005-03-04 22:39 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |4.0.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19673
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2005-03-04 22:39 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-01-28 16:46 [Bug fortran/19673] New: pointer function with RESULT specified returns pointer to "ptr" rather than "*ptr" paulthomas2 at wanadoo dot fr
2005-03-03 22:00 ` [Bug fortran/19673] " tobi at gcc dot gnu dot org
2005-03-03 22:08 ` tobi at gcc dot gnu dot org
2005-03-03 22:17 ` tobi at gcc dot gnu dot org
2005-03-03 22:44 ` paulthomas2 at wanadoo dot fr
2005-03-03 22:54 ` tobi at gcc dot gnu dot org
2005-03-03 23:24 ` paulthomas2 at wanadoo dot fr
2005-03-04 21:04 ` cvs-commit at gcc dot gnu dot org
2005-03-04 22:21 ` cvs-commit at gcc dot gnu dot org
2005-03-04 22:29 ` tobi at gcc dot gnu dot org
2005-03-04 22:39 ` tobi 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).