diff options
author | Paul Thomas <pault@gcc.gnu.org> | 2023-06-21 17:01:57 +0100 |
---|---|---|
committer | Paul Thomas <pault@gcc.gnu.org> | 2023-06-21 17:01:57 +0100 |
commit | caf0892eea67349d9a1e44590c3440768136fe2b (patch) | |
tree | 94d32781ab5a52199427ae95ecbe1fe0a63c5515 /gcc/fortran | |
parent | b9401c3a323c59705eca177bf72c13c0d2f462b6 (diff) | |
download | gcc-caf0892eea67349d9a1e44590c3440768136fe2b.zip gcc-caf0892eea67349d9a1e44590c3440768136fe2b.tar.gz gcc-caf0892eea67349d9a1e44590c3440768136fe2b.tar.bz2 |
Fortran: Seg fault passing string to type cptr dummy [PR108961].
2023-06-21 Paul Thomas <pault@gcc.gnu.org>
gcc/fortran
PR fortran/108961
* trans-expr.cc (gfc_conv_procedure_call): The hidden string
length must not be passed to a formal arg of type(cptr).
gcc/testsuite/
PR fortran/108961
* gfortran.dg/pr108961.f90: New test.
Diffstat (limited to 'gcc/fortran')
-rw-r--r-- | gcc/fortran/trans-expr.cc | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc index 45a984b..3c209bc 100644 --- a/gcc/fortran/trans-expr.cc +++ b/gcc/fortran/trans-expr.cc @@ -7348,11 +7348,14 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym, } /* Character strings are passed as two parameters, a length and a - pointer - except for Bind(c) which only passes the pointer. + pointer - except for Bind(c) and c_ptrs which only passe the pointer. An unlimited polymorphic formal argument likewise does not need the length. */ if (parmse.string_length != NULL_TREE && !sym->attr.is_bind_c + && !(fsym && fsym->ts.type == BT_DERIVED && fsym->ts.u.derived + && fsym->ts.u.derived->intmod_sym_id == ISOCBINDING_PTR + && fsym->ts.u.derived->from_intmod == INTMOD_ISO_C_BINDING ) && !(fsym && UNLIMITED_POLY (fsym))) vec_safe_push (stringargs, parmse.string_length); |