diff mbox series

[fortran] PR108961 - Segfault when associating to pointer from C_F_POINTER

Message ID CAGkQGiKCiHkaBpuXXPD7_cG8O-P+tWju=CFCw9eiwLCZLvnOtw@mail.gmail.com
State New
Headers show
Series [fortran] PR108961 - Segfault when associating to pointer from C_F_POINTER | expand

Commit Message

Paul Richard Thomas June 20, 2023, 4:19 p.m. UTC
Dear All,

This patch is verging on obvious. The PR was originally, incorrectly
blocking PR87477 and the testcase has remained in my 'associate'
directory. I thought that it is time to get shot of it!

Is there a better way to detect a type(c_ptr) formal argument?

Subject to advice on the question, OK for trunk?

Paul

Comments

Tobias Burnus June 20, 2023, 4:30 p.m. UTC | #1
On 20.06.23 18:19, Paul Richard Thomas via Fortran wrote:

> Is there a better way to detect a type(c_ptr) formal argument?
u.derived->intmod_sym_id == ISOCBINDING_PTR ?

Tobias

-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955
Mikael Morin June 20, 2023, 8:47 p.m. UTC | #2
Le 20/06/2023 à 18:30, Tobias Burnus a écrit :
> On 20.06.23 18:19, Paul Richard Thomas via Fortran wrote:
> 
>> Is there a better way to detect a type(c_ptr) formal argument?
> u.derived->intmod_sym_id == ISOCBINDING_PTR ?
	&& u.derived->from_intmod == INTMOD_ISO_C_BINDING ?
Paul Richard Thomas June 21, 2023, 4:08 p.m. UTC | #3
Committed as r14-2021-gcaf0892eea67349d9a1e44590c3440768136fe2b

Thanks for the pointers, Tobias and Mikael, I used them both.

Paul

On Tue, 20 Jun 2023 at 21:47, Mikael Morin <morin-mikael@orange.fr> wrote:
>
> Le 20/06/2023 à 18:30, Tobias Burnus a écrit :
> > On 20.06.23 18:19, Paul Richard Thomas via Fortran wrote:
> >
> >> Is there a better way to detect a type(c_ptr) formal argument?
> > u.derived->intmod_sym_id == ISOCBINDING_PTR ?
>         && u.derived->from_intmod == INTMOD_ISO_C_BINDING ?
>
diff mbox series

Patch

diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc
index 45a984b6bdb..0823efd5abc 100644
--- a/gcc/fortran/trans-expr.cc
+++ b/gcc/fortran/trans-expr.cc
@@ -7353,6 +7353,8 @@  gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
 	 need the length.  */
       if (parmse.string_length != NULL_TREE
 	  && !sym->attr.is_bind_c
+	  && !(fsym && fsym->ts.type == BT_DERIVED
+	       && !strcmp (fsym->ts.u.derived->name, "c_ptr"))
 	  && !(fsym && UNLIMITED_POLY (fsym)))
 	vec_safe_push (stringargs, parmse.string_length);