public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/104100] New: Passing an allocated array to a C bind function alters the bounds
@ 2022-01-18 16:53 hzhou321 at anl dot gov
2022-01-18 22:01 ` [Bug fortran/104100] " kargl at gcc dot gnu.org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: hzhou321 at anl dot gov @ 2022-01-18 16:53 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104100
Bug ID: 104100
Summary: Passing an allocated array to a C bind function alters
the bounds
Product: gcc
Version: 11.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: hzhou321 at anl dot gov
Target Milestone: ---
https://github.com/pmodels/mpich/issues/4170#issuecomment-1015580478
Minimum reproducer:
`t.f90`:
```
program t
INTERFACE
SUBROUTINE F_cdesc(buf) bind(C, name="F_cdesc")
IMPLICIT NONE
TYPE(*), DIMENSION(..), INTENT(in) :: buf
END SUBROUTINE
END INTERFACE
! Only reproducible with allocatable array. "INTEGER:: A(5)" would be fine.
INTEGER, allocatable, dimension(:):: A
allocate(A(5))
A = (/1, 2, 3, 4, 5/);
print*, A
write(*,'(a6,2(1x,i2))') 'Before:', lbound(A), ubound(A)
! "CALL F_cdesc(A)" would be fine
CALL f08ts(A)
print*, A
write(*,'(a6,2(1x,i2))') 'After:', lbound(A), ubound(A)
deallocate(A)
contains
SUBROUTINE f08ts(buf)
IMPLICIT NONE
TYPE(*), DIMENSION(..), INTENT(in) :: buf
call F_cdesc(buf)
END SUBROUTINE f08ts
end
```
`cdesc.c`:
```
#include <ISO_Fortran_binding.h>
void F_cdesc(CFI_cdesc_t *buf) { }
```
Run with:
```
gcc-9 -c -o cdesc.o cdesc.c && gfortran-9 t.f90 cdesc.o -o t && ./t
```
Results:
```
1 2 3 4 5
Before 1 5
1 2 3 4 5
After: 0 4
```
EDIT: also reproduced with `gcc 11`
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/104100] Passing an allocated array to a C bind function alters the bounds
2022-01-18 16:53 [Bug fortran/104100] New: Passing an allocated array to a C bind function alters the bounds hzhou321 at anl dot gov
@ 2022-01-18 22:01 ` kargl at gcc dot gnu.org
2022-01-18 22:15 ` hzhou321 at anl dot gov
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: kargl at gcc dot gnu.org @ 2022-01-18 22:01 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104100
kargl at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |kargl at gcc dot gnu.org
Known to work| |12.0
--- Comment #1 from kargl at gcc dot gnu.org ---
Works with 12.0
% ~/work/bin/gcc -c -O aa.c
% gfcx -o z a.f90 -O aa.o
% ./z
1 2 3 4 5
Before 1 5
1 2 3 4 5
After: 1 5
Thanks for the bug report, but it should likely be closed with
WONTFIX due to the complexity of the changes to ISO_Fortran_binding.h
and CFI support. I'll let active gfortran contributors make that
decision.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/104100] Passing an allocated array to a C bind function alters the bounds
2022-01-18 16:53 [Bug fortran/104100] New: Passing an allocated array to a C bind function alters the bounds hzhou321 at anl dot gov
2022-01-18 22:01 ` [Bug fortran/104100] " kargl at gcc dot gnu.org
@ 2022-01-18 22:15 ` hzhou321 at anl dot gov
2022-01-18 22:37 ` sgk at troutmask dot apl.washington.edu
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: hzhou321 at anl dot gov @ 2022-01-18 22:15 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104100
--- Comment #2 from Hui Zhou <hzhou321 at anl dot gov> ---
Great! That means it has already been fixed in the coming 12 series, right? I
was initially a bit confused with your WONTFIX comment.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/104100] Passing an allocated array to a C bind function alters the bounds
2022-01-18 16:53 [Bug fortran/104100] New: Passing an allocated array to a C bind function alters the bounds hzhou321 at anl dot gov
2022-01-18 22:01 ` [Bug fortran/104100] " kargl at gcc dot gnu.org
2022-01-18 22:15 ` hzhou321 at anl dot gov
@ 2022-01-18 22:37 ` sgk at troutmask dot apl.washington.edu
2022-01-19 10:19 ` rguenth at gcc dot gnu.org
2022-01-19 16:05 ` sandra at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: sgk at troutmask dot apl.washington.edu @ 2022-01-18 22:37 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104100
--- Comment #3 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
On Tue, Jan 18, 2022 at 10:15:25PM +0000, hzhou321 at anl dot gov wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104100
>
> --- Comment #2 from Hui Zhou <hzhou321 at anl dot gov> ---
> Great! That means it has already been fixed in the coming 12 series, right? I
> was initially a bit confused with your WONTFIX comment.
>
Yes, it is fixed in the mainline of development, which is
expected to be branched for 12.1 in a few days/week. The
changes are fairly extensive. I don't know if there are
plans to backport to 11-branch.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/104100] Passing an allocated array to a C bind function alters the bounds
2022-01-18 16:53 [Bug fortran/104100] New: Passing an allocated array to a C bind function alters the bounds hzhou321 at anl dot gov
` (2 preceding siblings ...)
2022-01-18 22:37 ` sgk at troutmask dot apl.washington.edu
@ 2022-01-19 10:19 ` rguenth at gcc dot gnu.org
2022-01-19 16:05 ` sandra at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-01-19 10:19 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104100
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2022-01-19
CC| |sandra at codesourcery dot com
Ever confirmed|0 |1
--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
eventually some pieces might qualify for backporting, lets ask Sandra.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/104100] Passing an allocated array to a C bind function alters the bounds
2022-01-18 16:53 [Bug fortran/104100] New: Passing an allocated array to a C bind function alters the bounds hzhou321 at anl dot gov
` (3 preceding siblings ...)
2022-01-19 10:19 ` rguenth at gcc dot gnu.org
@ 2022-01-19 16:05 ` sandra at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: sandra at gcc dot gnu.org @ 2022-01-19 16:05 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104100
sandra at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |sandra at gcc dot gnu.org
--- Comment #5 from sandra at gcc dot gnu.org ---
Most of the patches are on the devel/omp/gcc-11 development branch that also
includes a bunch of other experimental features and preliminary patches that
haven't made it to mainline yet, but I don't think either Tobias or I have a
todo item to backport the bind(c) patches to the stable gcc 11 branch. There
were a lot of patches and some of them were quite extensive rewrites, so my
sense is that it's probably not appropriate for a stable branch.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-01-19 16:05 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-18 16:53 [Bug fortran/104100] New: Passing an allocated array to a C bind function alters the bounds hzhou321 at anl dot gov
2022-01-18 22:01 ` [Bug fortran/104100] " kargl at gcc dot gnu.org
2022-01-18 22:15 ` hzhou321 at anl dot gov
2022-01-18 22:37 ` sgk at troutmask dot apl.washington.edu
2022-01-19 10:19 ` rguenth at gcc dot gnu.org
2022-01-19 16:05 ` sandra at gcc dot gnu.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).