public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libfortran/40187] New: c_f_pointer with stride in SHAPE
@ 2009-05-18 17:58 tkoenig at gcc dot gnu dot org
2009-05-18 21:20 ` [Bug libfortran/40187] " burnus at gcc dot gnu dot org
` (9 more replies)
0 siblings, 10 replies; 11+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2009-05-18 17:58 UTC (permalink / raw)
To: gcc-bugs
Using a SHAPE with stride doesn't work with c_f_pointer doesn't work
(modified test case from the testsuite):
$ diff -u c_f_pointer_shape_tests_4.f03
~/gcc/trunk/gcc/testsuite/gfortran.dg/c_f_pointer_shape_tests_2.f03
--- c_f_pointer_shape_tests_4.f03 2009-05-18 19:55:36.000000000 +0200
+++
/home/ig25/gcc/trunk/gcc/testsuite/gfortran.dg/c_f_pointer_shape_tests_2.f03
2007-11-17 17:27:32.000000000 +0100
@@ -29,13 +29,12 @@
integer(c_int), value :: num_rows
integer(c_int), value :: num_cols
integer, dimension(:,:), pointer :: myArrayPtr
- integer(c_long_long), dimension(3) :: shape
+ integer(c_long_long), dimension(2) :: shape
integer :: i,j
shape(1) = num_rows
- shape(2) = -3;
- shape(3) = num_cols
- call c_f_pointer(cPtr, myArrayPtr, shape(1:3:2))
+ shape(2) = num_cols
+ call c_f_pointer(cPtr, myArrayPtr, shape)
do j = 1, num_cols
do i = 1, num_rows
if(myArrayPtr(i,j) /= ((j-1)*num_rows)+(i-1)) call abort ()
$ gfortran
~/gcc/trunk/gcc/testsuite/gfortran.dg/c_f_pointer_shape_tests_2_driver.c
c_f_pointer_shape_tests_4.f03
$ ./a.out
Aborted
--
Summary: c_f_pointer with stride in SHAPE
Product: gcc
Version: 4.5.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P3
Component: libfortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: tkoenig at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40187
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libfortran/40187] c_f_pointer with stride in SHAPE
2009-05-18 17:58 [Bug libfortran/40187] New: c_f_pointer with stride in SHAPE tkoenig at gcc dot gnu dot org
@ 2009-05-18 21:20 ` burnus at gcc dot gnu dot org
2009-05-19 5:07 ` pault at gcc dot gnu dot org
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: burnus at gcc dot gnu dot org @ 2009-05-18 21:20 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from burnus at gcc dot gnu dot org 2009-05-18 21:20 -------
Can you attach a working example? I failed to apply your patch and figure out
which diffed file is what.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40187
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libfortran/40187] c_f_pointer with stride in SHAPE
2009-05-18 17:58 [Bug libfortran/40187] New: c_f_pointer with stride in SHAPE tkoenig at gcc dot gnu dot org
2009-05-18 21:20 ` [Bug libfortran/40187] " burnus at gcc dot gnu dot org
@ 2009-05-19 5:07 ` pault at gcc dot gnu dot org
2009-05-19 17:14 ` tkoenig at gcc dot gnu dot org
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: pault at gcc dot gnu dot org @ 2009-05-19 5:07 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from pault at gcc dot gnu dot org 2009-05-19 05:06 -------
(In reply to comment #1)
> Can you attach a working example? I failed to apply your patch and figure out
> which diffed file is what.
>
Hi Tobias,
It's a reversed diff!
Hi Thomas,
Works for me on FC9/x86_64 - what platform are you reporting?
Cheers
Paul
--
pault at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |burnus at gcc dot gnu dot
| |org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40187
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libfortran/40187] c_f_pointer with stride in SHAPE
2009-05-18 17:58 [Bug libfortran/40187] New: c_f_pointer with stride in SHAPE tkoenig at gcc dot gnu dot org
2009-05-18 21:20 ` [Bug libfortran/40187] " burnus at gcc dot gnu dot org
2009-05-19 5:07 ` pault at gcc dot gnu dot org
@ 2009-05-19 17:14 ` tkoenig at gcc dot gnu dot org
2009-05-19 17:18 ` tkoenig at gcc dot gnu dot org
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2009-05-19 17:14 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from tkoenig at gcc dot gnu dot org 2009-05-19 17:14 -------
Created an attachment (id=17893)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=17893&action=view)
Failing test case
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40187
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libfortran/40187] c_f_pointer with stride in SHAPE
2009-05-18 17:58 [Bug libfortran/40187] New: c_f_pointer with stride in SHAPE tkoenig at gcc dot gnu dot org
` (2 preceding siblings ...)
2009-05-19 17:14 ` tkoenig at gcc dot gnu dot org
@ 2009-05-19 17:18 ` tkoenig at gcc dot gnu dot org
2009-05-19 17:18 ` tkoenig at gcc dot gnu dot org
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2009-05-19 17:18 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from tkoenig at gcc dot gnu dot org 2009-05-19 17:17 -------
Created an attachment (id=17894)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=17894&action=view)
Driver for failing test case (identical to c_f_pointer_shape_tests_2_driver.c)
$ gfortran c_f_pointer_shape_tests_4_driver.c c_f_pointer_shape_tests_4.f03
$ ./a.out
Aborted
$ gfortran -v
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../../../gcc/branches/fortran-dev/configure
--prefix=/home/ig25 --enable-languages=c,fortran --enable-maintainer-mode
Thread model: posix
gcc version 4.5.0 20090506 (experimental) (GCC)
The reason this fails is fairly obvious if you look at the code: In
c_f_pointer_u0, there's
for (i = 0; i < shapeSize; i++)
{
/* Lower bound is 1, as specified by the draft. */
f_ptr_out->dim[i].lbound = 1;
/* Have to allow for the SHAPE array to be any valid kind for
an INTEGER type. */
#ifdef HAVE_GFC_INTEGER_1
if (GFC_DESCRIPTOR_SIZE (shape) == 1)
f_ptr_out->dim[i].ubound = ((GFC_INTEGER_1 *) (shape->data))[i];
which ignores the (sad) fact that shape could have a stride not equal
to one. I found this when trying to convert this part to the array access
macros.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40187
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libfortran/40187] c_f_pointer with stride in SHAPE
2009-05-18 17:58 [Bug libfortran/40187] New: c_f_pointer with stride in SHAPE tkoenig at gcc dot gnu dot org
` (3 preceding siblings ...)
2009-05-19 17:18 ` tkoenig at gcc dot gnu dot org
@ 2009-05-19 17:18 ` tkoenig at gcc dot gnu dot org
2009-05-27 5:27 ` tkoenig at gcc dot gnu dot org
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2009-05-19 17:18 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from tkoenig at gcc dot gnu dot org 2009-05-19 17:18 -------
Since I'm working in this area anyway, I might as well take this.
--
tkoenig at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |tkoenig at gcc dot gnu dot
|dot org |org
Status|UNCONFIRMED |ASSIGNED
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2009-05-19 17:18:27
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40187
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libfortran/40187] c_f_pointer with stride in SHAPE
2009-05-18 17:58 [Bug libfortran/40187] New: c_f_pointer with stride in SHAPE tkoenig at gcc dot gnu dot org
` (4 preceding siblings ...)
2009-05-19 17:18 ` tkoenig at gcc dot gnu dot org
@ 2009-05-27 5:27 ` tkoenig at gcc dot gnu dot org
2009-05-30 13:17 ` tkoenig at gcc dot gnu dot org
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2009-05-27 5:27 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from tkoenig at gcc dot gnu dot org 2009-05-27 05:27 -------
Subject: Bug 40187
Author: tkoenig
Date: Wed May 27 05:27:31 2009
New Revision: 147894
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=147894
Log:
2009-05-27 Thomas Koenig <tkoenig@gcc.gnu.org>
PR libfortran/40187
* intrinsics/iso_c_binding.c (c_f_pointer_u0): Take care
of stride in "shape" argument.
2009-05-27 Thomas Koenig <tkoenig@gcc.gnu.org>
PR libfortran/40187
* gfortran.dg/c_f_pointer_shape_tests_4.f03: New file.
* gfortran.dg/c_f_pointer_shape_tests_4_driver.c: New file.
Added:
trunk/gcc/testsuite/gfortran.dg/c_f_pointer_shape_tests_4.f03
trunk/gcc/testsuite/gfortran.dg/c_f_pointer_shape_tests_4_driver.c
Modified:
trunk/gcc/testsuite/ChangeLog
trunk/libgfortran/ChangeLog
trunk/libgfortran/intrinsics/iso_c_binding.c
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40187
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libfortran/40187] c_f_pointer with stride in SHAPE
2009-05-18 17:58 [Bug libfortran/40187] New: c_f_pointer with stride in SHAPE tkoenig at gcc dot gnu dot org
` (5 preceding siblings ...)
2009-05-27 5:27 ` tkoenig at gcc dot gnu dot org
@ 2009-05-30 13:17 ` tkoenig at gcc dot gnu dot org
2009-06-07 14:24 ` tkoenig at gcc dot gnu dot org
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2009-05-30 13:17 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from tkoenig at gcc dot gnu dot org 2009-05-30 13:17 -------
Subject: Bug 40187
Author: tkoenig
Date: Sat May 30 13:17:14 2009
New Revision: 148002
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=148002
Log:
2009-05-30 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/37577
PR libfortran/40187
* runtime/in_pack_generic (internal_pack): Remove unnecessary
test for stride == 0.
* runtime/in_unpack_generic.c (internal_unpack): Likewise.
* intrinsics/iso_c_binding.c (c_f_pointer_u0): Take care
of stride in "shape" argument. Use array access macros for
accessing array descriptors.
* libgfortran.h (struct descriptor_dimension): Change stride
to _stride, lbound to _lbound and ubound to _ubound.
(GFC_DIMENSION_LBOUND): Use new name(s) in struct
descriptor_dimension.
(GFC_DIMENSION_UBOUND): Likewise.
(GFC_DIMENSION_STRIDE): Likewise.
(GFC_DIMENSION_EXTENT): Likewise.
(GFC_DIMENSION_SET): Likewise.
(GFC_DESCRIPTOR_LBOUND): Likewise.
(GFC_DESCRIPTOR_UBOUND): Likewise.
(GFC_DESCRIPTOR_EXTENT): Likewise.
(GFC_DESCRIPTOR_STRIDE): Likewise.
* io/transfer.c (transfer_array): Use array access macros.
Use byte-sized strides.
2009-05-30 Thomas Koenig <tkoenig@gcc.gnu.org>
PR libfortran/40187
* gfortran.dg/c_f_pointer_shape_tests_4.f03: New file.
* gfortran.dg/c_f_pointer_shape_tests_4_driver.c: New file.
Added:
branches/fortran-dev/gcc/testsuite/gfortran.dg/c_f_pointer_shape_tests_4.f03
branches/fortran-dev/gcc/testsuite/gfortran.dg/c_f_pointer_shape_tests_4_driver.c
Modified:
branches/fortran-dev/gcc/testsuite/ChangeLog.fortran-dev
branches/fortran-dev/libgfortran/ChangeLog.dev
branches/fortran-dev/libgfortran/intrinsics/iso_c_binding.c
branches/fortran-dev/libgfortran/io/transfer.c
branches/fortran-dev/libgfortran/libgfortran.h
branches/fortran-dev/libgfortran/runtime/in_pack_generic.c
branches/fortran-dev/libgfortran/runtime/in_unpack_generic.c
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40187
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libfortran/40187] c_f_pointer with stride in SHAPE
2009-05-18 17:58 [Bug libfortran/40187] New: c_f_pointer with stride in SHAPE tkoenig at gcc dot gnu dot org
` (6 preceding siblings ...)
2009-05-30 13:17 ` tkoenig at gcc dot gnu dot org
@ 2009-06-07 14:24 ` tkoenig at gcc dot gnu dot org
2009-06-07 14:37 ` burnus at gcc dot gnu dot org
2009-07-27 9:11 ` tkoenig at gcc dot gnu dot org
9 siblings, 0 replies; 11+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2009-06-07 14:24 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from tkoenig at gcc dot gnu dot org 2009-06-07 14:24 -------
Does this need a 4.4 backport? I'm inclined to think not.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40187
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libfortran/40187] c_f_pointer with stride in SHAPE
2009-05-18 17:58 [Bug libfortran/40187] New: c_f_pointer with stride in SHAPE tkoenig at gcc dot gnu dot org
` (7 preceding siblings ...)
2009-06-07 14:24 ` tkoenig at gcc dot gnu dot org
@ 2009-06-07 14:37 ` burnus at gcc dot gnu dot org
2009-07-27 9:11 ` tkoenig at gcc dot gnu dot org
9 siblings, 0 replies; 11+ messages in thread
From: burnus at gcc dot gnu dot org @ 2009-06-07 14:37 UTC (permalink / raw)
To: gcc-bugs
------- Comment #9 from burnus at gcc dot gnu dot org 2009-06-07 14:37 -------
> Does this need a 4.4 backport? I'm inclined to think not.
Good question. As it is no regression, backporting is not required; it is a
wrong-code bug, but strides are rather special. Thus for me either is OK -
backporting or just closing as FIXED.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40187
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libfortran/40187] c_f_pointer with stride in SHAPE
2009-05-18 17:58 [Bug libfortran/40187] New: c_f_pointer with stride in SHAPE tkoenig at gcc dot gnu dot org
` (8 preceding siblings ...)
2009-06-07 14:37 ` burnus at gcc dot gnu dot org
@ 2009-07-27 9:11 ` tkoenig at gcc dot gnu dot org
9 siblings, 0 replies; 11+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2009-07-27 9:11 UTC (permalink / raw)
To: gcc-bugs
------- Comment #10 from tkoenig at gcc dot gnu dot org 2009-07-27 09:11 -------
Closing (fixed).
--
tkoenig at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40187
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2009-07-27 9:11 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-18 17:58 [Bug libfortran/40187] New: c_f_pointer with stride in SHAPE tkoenig at gcc dot gnu dot org
2009-05-18 21:20 ` [Bug libfortran/40187] " burnus at gcc dot gnu dot org
2009-05-19 5:07 ` pault at gcc dot gnu dot org
2009-05-19 17:14 ` tkoenig at gcc dot gnu dot org
2009-05-19 17:18 ` tkoenig at gcc dot gnu dot org
2009-05-19 17:18 ` tkoenig at gcc dot gnu dot org
2009-05-27 5:27 ` tkoenig at gcc dot gnu dot org
2009-05-30 13:17 ` tkoenig at gcc dot gnu dot org
2009-06-07 14:24 ` tkoenig at gcc dot gnu dot org
2009-06-07 14:37 ` burnus at gcc dot gnu dot org
2009-07-27 9:11 ` tkoenig 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).