On Mon, Nov 10, 2025 at 10:30 PM Yuao Ma <[email protected]> wrote:
>
> Hi Tobias,
>
> On Tue, Nov 4, 2025 at 9:10 PM Tobias Burnus <[email protected]> wrote:
> > If you go for that route, I think we want to have a sorry
> > for the FIXME issues in expr-1 and those in expr-3. And for
> > the code in 'conv_dummy_value', I think a comment would be good
> > why that's called for conditional expr, possibly with a FIXME
> > about the missing bits.
> >
>
> Thank you so much for the test cases! They've been really helpful -
> not only do they highlight some issues with the .NIL. implementation,
> but they've also uncovered some existing bugs in the current trunk.
> Rather than merging this with the risk of introducing new bugs, I plan
> to fix the current bugs first.
>
> The attached patch primarily focuses on fixing the problem exposed by
> cond-expr-3.f90, where dummy argument presence is not being identified
> correctly. It turns out that to handle this situation properly, we
> need to modify both gfc_conv_missing_dummy and conv_dummy_value.
> Specifically, in conv_dummy_value, simply forwarding the call to
> EXPR_VARIABLE isn't sufficient, so I've chosen a new approach in the
> patch. I've also slightly enhanced the test case so that it now tests
> all four combinations of value/reference.
>
> Regarding the implementation details, I'm not entirely sure about the
> current approach. I think the changes to conv_dummy_value are fine,
> but for gfc_conv_missing_dummy, the current recursive approach seems
> to have repeated preconditions - for example, we're checking whether
> the attr is optional both inside and outside the function body. Since
> this function is only called twice (once for user-defined functions
> and once for intrinsics), I think there might be a better design. I'd
> love to hear your thoughts on this.
>
> Finally, sorry for the late reply! It really took me some time to
> handle this correctly... I'll address pointers/allocators next.
>

Looking at my attached patch, I immediately found 2 bugs:
1. A typo that changes rse to lse.
2. In conv_dummy_value, in addition to handling the optionalarg, we
also need to handle se->expr.
After fixing these two issues, some of the cond-expr-1 tests now work.
However, cond-expr-2 is experiencing some segfaults.

Note that even without cond-expr, the current trunk still has bugs
related to dummy value/reference, dating back to gfortran 14:
https://godbolt.org/z/3aGM6enjv. I will work on fixing this.

By the way, could you please update the status of
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122342? I believe it is
now resolved.

Thanks,
Yuao

Reply via email to