diff options
author | Tobias Burnus <tobias@codesourcery.com> | 2023-02-25 11:55:08 +0100 |
---|---|---|
committer | Tobias Burnus <tobias@codesourcery.com> | 2023-02-25 11:55:42 +0100 |
commit | d3e427f684b0cd7cedbe7b93a06f455e562c5901 (patch) | |
tree | f3c68b810b06cc09a7c1e5ebe27b5cf90844e3ba /libgfortran/generated | |
parent | 4341106354c6a463ce3628a4ef9c1a1d37193b59 (diff) | |
download | gcc-d3e427f684b0cd7cedbe7b93a06f455e562c5901.zip gcc-d3e427f684b0cd7cedbe7b93a06f455e562c5901.tar.gz gcc-d3e427f684b0cd7cedbe7b93a06f455e562c5901.tar.bz2 |
Fortran: Skip bound conv in gfc_conv_gfc_desc_to_cfi_desc with intent(out) ptr [PR108621]
When the dummy argument of the bind(C) proc is 'pointer, intent(out)', the conversion
of the GFC to the CFI bounds can be skipped: it is not needed and avoids issues with
noninit memory.
Note that the 'cfi->base_addr = gfc->addr' assignment is kept as the C code of a user
might assume that a nullified pointer arrives as NULL (or even a specific value).
For instance, gfortran.dg/c-interop/section-{1,2}.f90 assumes the value NULL.
Note 2: The PR is about a may-be-uninitialized warning with intent(out). In the PR's
testcase, the pointer was nullified and should not have produced that warning.
That is a diagnostic issue, now tracked as PR middle-end/108906 as the issue in principle
still exists (e.g. with 'intent(inout)'). [But no longer for intent(out).]
Note 3: With undefined pointers and no 'intent', accessing uninit memory is unavoidable
on the caller side as the compiler cannot know what the C function does (but this usage
determines whether the pointer is permitted be undefined or whether the bounds must be
gfc-to-cfi converted).
gcc/fortran/ChangeLog:
PR fortran/108621
* trans-expr.cc (gfc_conv_gfc_desc_to_cfi_desc): Skip setting of
bounds of CFI desc for 'pointer,intent(out)'.
gcc/testsuite/ChangeLog:
PR fortran/108621
* gfortran.dg/c-interop/fc-descriptor-pr108621.f90: New test.
Diffstat (limited to 'libgfortran/generated')
0 files changed, 0 insertions, 0 deletions