On Wed, Dec 18, 2024 at 10:09:26AM -0800, Jerry D wrote: > On 12/18/24 4:11 AM, Harald Anlauf wrote: > > Hi Steve, > > > > thanks for the draft patch. > > > > I haven't looked close enough, but you may have to add support > > for 'asis' being an optional dummy variable. The following > > example crashes here with a segfault: > >
(program snipped) > > --- snip --- > > This is interesting. In my tests I tried: > > print *, len(s1), len(f_c_string(s1)) > > Which works fine. Is the user required to check for the presence of the > optional argument before using it? From the 'view' of the subroutine 'asis' > exists but is undefined. > See F2023, 15.5.2.13. An optional dummy argument that is not present is subject to the following restrictions. (list of 12 restrictions, none apply) Except as noted in the list above, it may be supplied as an actual argument corresponding to an optional dummy argument, which is then also considered not to be present. So, it seems that this section of the patch + gfc_init_se (&asis_se, se); + gfc_conv_expr (&asis_se, asis); + gfc_add_block_to_block (&se->pre, &asis_se.pre); + tmp = fold_build3_loc (input_location, COND_EXPR, void_type_node, + asis_se.expr, then_branch, else_branch); needs to be protected by some code that starts with present = gfc_conv_expr_present (asis->symtree->n.sym); -- Steve