public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/25396] New: Operator overloading for array-valued functions gets shape incorrectly
@ 2005-12-13 17:56 jb at gcc dot gnu dot org
2005-12-27 19:26 ` [Bug fortran/25396] " eedelman at gcc dot gnu dot org
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: jb at gcc dot gnu dot org @ 2005-12-13 17:56 UTC (permalink / raw)
To: gcc-bugs
Consider the following testcase:
module geometry
implicit none
interface operator(.cross.)
module procedure cross
end interface
contains
! Cross product between two 3d vectors.
pure function cross(a, b)
real, dimension(3), intent(in) :: a,b
real, dimension(3) :: cross
cross = (/ a(2) * b(3) - a(3) * b(2), &
a(3) * b(1) - a(1) * b(3), &
a(1) * b(2) - a(2) * b(1) /)
end function cross
end module geometry
program opshape
use geometry
implicit none
real :: t(3,3), a(3), b(3)
! Storing to an array works.
b = t(:,2) .cross. t(:,3)
! However, when the result is not stored it doesn't work.
! Following two line are equivalent, but the first one causes an
! error.
print *, size (t(:,2) .cross. t(:,3))
print *, size (cross (t(:,2), t(:,3)))
! Same here.
a = dot_product (t(:,1), t(:,2) .cross. t(:,3))
a = dot_product (t(:,1), cross (t(:,2), t(:,3)))
end program opshape
The two dot_product and the two size invocations are equivalent, but the ones
that use the operator .cross. instead of calling the cross function directly,
cause errors:
~/src/gfortran/test/opshape% gfortran opshape.f90
In file opshape.f90:37
print *, size (t(:,2) .cross. t(:,3))
1
Error: 'array' argument of 'size' intrinsic at (1) must be an array
In file opshape.f90:41
a = dot_product (t(:,1), t(:,2) .cross. t(:,3))
1
Error: 'vector_b' argument of 'dot_product' intrinsic at (1) must be of rank 1
--
Summary: Operator overloading for array-valued functions gets
shape incorrectly
Product: gcc
Version: 4.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: jb at gcc dot gnu dot org
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25396
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/25396] Operator overloading for array-valued functions gets shape incorrectly
2005-12-13 17:56 [Bug fortran/25396] New: Operator overloading for array-valued functions gets shape incorrectly jb at gcc dot gnu dot org
@ 2005-12-27 19:26 ` eedelman at gcc dot gnu dot org
2005-12-29 20:01 ` eedelman at gcc dot gnu dot org
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: eedelman at gcc dot gnu dot org @ 2005-12-27 19:26 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from eedelman at gcc dot gnu dot org 2005-12-27 19:26 -------
Confirmed.
--
eedelman at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |eedelman at gcc dot gnu dot
| |org
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2005-12-27 19:26:24
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25396
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/25396] Operator overloading for array-valued functions gets shape incorrectly
2005-12-13 17:56 [Bug fortran/25396] New: Operator overloading for array-valued functions gets shape incorrectly jb at gcc dot gnu dot org
2005-12-27 19:26 ` [Bug fortran/25396] " eedelman at gcc dot gnu dot org
@ 2005-12-29 20:01 ` eedelman at gcc dot gnu dot org
2005-12-29 20:57 ` eedelman at gcc dot gnu dot org
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: eedelman at gcc dot gnu dot org @ 2005-12-29 20:01 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from eedelman at gcc dot gnu dot org 2005-12-29 20:01 -------
Working on a patch.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25396
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/25396] Operator overloading for array-valued functions gets shape incorrectly
2005-12-13 17:56 [Bug fortran/25396] New: Operator overloading for array-valued functions gets shape incorrectly jb at gcc dot gnu dot org
2005-12-27 19:26 ` [Bug fortran/25396] " eedelman at gcc dot gnu dot org
2005-12-29 20:01 ` eedelman at gcc dot gnu dot org
@ 2005-12-29 20:57 ` eedelman at gcc dot gnu dot org
2005-12-30 15:02 ` eedelman at gcc dot gnu dot org
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: eedelman at gcc dot gnu dot org @ 2005-12-29 20:57 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from eedelman at gcc dot gnu dot org 2005-12-29 20:57 -------
I think this simple one-liner fixes the bug:
Index: interface.c
===================================================================
--- interface.c (revision 109139)
+++ interface.c (working copy)
@@ -1718,6 +1718,7 @@ gfc_extend_expr (gfc_expr * e)
e->value.function.actual = actual;
e->value.function.esym = NULL;
e->value.function.isym = NULL;
+ e->value.function.name = NULL;
if (gfc_pure (NULL) && !gfc_pure (sym))
{
but because of PR 22607, I can't test it properly.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25396
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/25396] Operator overloading for array-valued functions gets shape incorrectly
2005-12-13 17:56 [Bug fortran/25396] New: Operator overloading for array-valued functions gets shape incorrectly jb at gcc dot gnu dot org
` (2 preceding siblings ...)
2005-12-29 20:57 ` eedelman at gcc dot gnu dot org
@ 2005-12-30 15:02 ` eedelman at gcc dot gnu dot org
2005-12-30 15:07 ` eedelman at gcc dot gnu dot org
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: eedelman at gcc dot gnu dot org @ 2005-12-30 15:02 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from eedelman at gcc dot gnu dot org 2005-12-30 15:02 -------
Subject: Bug 25396
Author: eedelman
Date: Fri Dec 30 15:02:44 2005
New Revision: 109171
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=109171
Log:
fortran/
2005-12-30 Erik Edelmann <eedelman@gcc.gnu.org>
PR fortran/22607
* trans-decl.c(gfc_get_extern_function_decl): Don't set
DECL_IS_PURE (fndecl) = 1 for return-by-reference
functions.
fortran/PR 25396
* interface.c (gfc_extend_expr): Initialize
e->value.function.name to NULL.
testsuite/
2005-12-30 Erik Edelmann <eedelman@gcc.gnu.org>
PR fortran/22607
* gfortran-dg/pure_byref_3.f90: New.
fortran/PR 25396
* gfortran.dg/userdef_operator_1.f90: New.
Added:
trunk/gcc/testsuite/gfortran.dg/pure_byref_3.f90
trunk/gcc/testsuite/gfortran.dg/userdef_operator_1.f90
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/interface.c
trunk/gcc/fortran/trans-decl.c
trunk/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25396
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/25396] Operator overloading for array-valued functions gets shape incorrectly
2005-12-13 17:56 [Bug fortran/25396] New: Operator overloading for array-valued functions gets shape incorrectly jb at gcc dot gnu dot org
` (3 preceding siblings ...)
2005-12-30 15:02 ` eedelman at gcc dot gnu dot org
@ 2005-12-30 15:07 ` eedelman at gcc dot gnu dot org
2005-12-30 15:11 ` eedelman at gcc dot gnu dot org
2005-12-31 16:39 ` tobi at gcc dot gnu dot org
6 siblings, 0 replies; 8+ messages in thread
From: eedelman at gcc dot gnu dot org @ 2005-12-30 15:07 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from eedelman at gcc dot gnu dot org 2005-12-30 15:07 -------
Subject: Bug 25396
Author: eedelman
Date: Fri Dec 30 15:07:48 2005
New Revision: 109172
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=109172
Log:
fortran/
2005-12-30 Erik Edelmann <eedelman@gcc.gnu.org>
PR fortran/22607
* trans-decl.c(gfc_get_extern_function_decl): Don't set
DECL_IS_PURE (fndecl) = 1 for return-by-reference
functions.
fortran/PR 25396
* interface.c (gfc_extend_expr): Initialize
e->value.function.name to NULL.
testsuite/
2005-12-30 Erik Edelmann <eedelman@gcc.gnu.org>
PR fortran/22607
* gfortran-dg/pure_byref_3.f90: New.
fortran/PR 25396
* gfortran.dg/userdef_operator_1.f90: New.
Added:
branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/pure_byref_3.f90
branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/userdef_operator_1.f90
Modified:
branches/gcc-4_1-branch/gcc/fortran/ChangeLog
branches/gcc-4_1-branch/gcc/fortran/interface.c
branches/gcc-4_1-branch/gcc/fortran/trans-decl.c
branches/gcc-4_1-branch/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25396
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/25396] Operator overloading for array-valued functions gets shape incorrectly
2005-12-13 17:56 [Bug fortran/25396] New: Operator overloading for array-valued functions gets shape incorrectly jb at gcc dot gnu dot org
` (4 preceding siblings ...)
2005-12-30 15:07 ` eedelman at gcc dot gnu dot org
@ 2005-12-30 15:11 ` eedelman at gcc dot gnu dot org
2005-12-31 16:39 ` tobi at gcc dot gnu dot org
6 siblings, 0 replies; 8+ messages in thread
From: eedelman at gcc dot gnu dot org @ 2005-12-30 15:11 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from eedelman at gcc dot gnu dot org 2005-12-30 15:11 -------
Subject: Bug 25396
Author: eedelman
Date: Fri Dec 30 15:11:15 2005
New Revision: 109173
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=109173
Log:
fortran/
2005-12-30 Erik Edelmann <eedelman@gcc.gnu.org>
PR fortran/22607
* trans-decl.c(gfc_get_extern_function_decl): Don't set
DECL_IS_PURE (fndecl) = 1 for return-by-reference
functions.
fortran/PR 25396
* interface.c (gfc_extend_expr): Initialize
e->value.function.name to NULL.
testsuite/
2005-12-30 Erik Edelmann <eedelman@gcc.gnu.org>
PR fortran/22607
* gfortran-dg/pure_byref_3.f90: New.
fortran/PR 25396
* gfortran.dg/userdef_operator_1.f90: New.
Added:
branches/gcc-4_0-branch/gcc/testsuite/gfortran.dg/pure_byref_3.f90
branches/gcc-4_0-branch/gcc/testsuite/gfortran.dg/userdef_operator_1.f90
Modified:
branches/gcc-4_0-branch/gcc/fortran/ChangeLog
branches/gcc-4_0-branch/gcc/fortran/interface.c
branches/gcc-4_0-branch/gcc/fortran/trans-decl.c
branches/gcc-4_0-branch/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25396
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/25396] Operator overloading for array-valued functions gets shape incorrectly
2005-12-13 17:56 [Bug fortran/25396] New: Operator overloading for array-valued functions gets shape incorrectly jb at gcc dot gnu dot org
` (5 preceding siblings ...)
2005-12-30 15:11 ` eedelman at gcc dot gnu dot org
@ 2005-12-31 16:39 ` tobi at gcc dot gnu dot org
6 siblings, 0 replies; 8+ messages in thread
From: tobi at gcc dot gnu dot org @ 2005-12-31 16:39 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from tobi at gcc dot gnu dot org 2005-12-31 16:39 -------
Fixed. BTW, Erik, you can use svn merge to backport patches to the older
branches. That would save you "svn add"ing them on all branches.
--
tobi at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |tobi at gcc dot gnu dot org
Status|NEW |RESOLVED
Resolution| |FIXED
Target Milestone|--- |4.0.3
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25396
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2005-12-31 16:39 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-12-13 17:56 [Bug fortran/25396] New: Operator overloading for array-valued functions gets shape incorrectly jb at gcc dot gnu dot org
2005-12-27 19:26 ` [Bug fortran/25396] " eedelman at gcc dot gnu dot org
2005-12-29 20:01 ` eedelman at gcc dot gnu dot org
2005-12-29 20:57 ` eedelman at gcc dot gnu dot org
2005-12-30 15:02 ` eedelman at gcc dot gnu dot org
2005-12-30 15:07 ` eedelman at gcc dot gnu dot org
2005-12-30 15:11 ` eedelman at gcc dot gnu dot org
2005-12-31 16: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).