Re: [PATCH} Fix fortran: [PR126170] Fix LTO ICE in copy_function_or_variable

Jerry D <[email protected]> Fri, 10 Jul 2026 09:44:32 -0700
Newsgroups gmane.comp.gcc.patches,gmane.comp.gcc.fortran
Message-ID <[email protected]>
On 7/10/26 7:24 AM, Paul Richard Thomas wrote:
> Hi Jerry,
> 
> This looks good to me, with a couple of wee grumbles:
> 
> (1) +      /* Same fix-up, for the finalizer wrapper symbol.  */
> These chunks are 346 lines apart. Entropy will not be increased by
> repeating the first comment.

Will do.>
> (2) s/CONTAINS'ed/contained/ :-)

Late night typing, what was I thinking! Fixed it last night and forgot to
redo the diff.

> 
> (3) Finally, since PR125051, which uncovered this one, was backported,
> surely this patch should be backported too?

Will do.>
> OK for mainline and backporting.
> 
> Thanks for the patch.
> 
> Paul

Thanks for the review.

> 
> On Fri, 10 Jul 2026 at 04:26, Jerry D <[email protected]> wrote:
>>
>> I all, the attached patch regression tested on x86_64
>>
>> I have not used the gfortran.dg/lto/ testsuite things so it took me a while to
>> come up with the test cases. Both are based on Andrew's original examples
>> provided in the PR.
>>
>> OK for mainline?
>>
>> I don't think we need to backport this. Let me know otherwise.
>>
>> Regards,
>>
>> Jerry
>> ---
>> fortran: [PR126170] Fix LTO ICE in copy_function_or_variable
>>
>>       A redundant USE of a module already visible via host association,
>>       written inside a contained procedure, caused gfortran's module
>>       reader to create a second copy of that module's derived
>>       type.
>>
>>       PR fortran/126170
>>
>>       gcc/fortran/ChangeLog:
>>
>>               PR fortran/126170
>>               * class.cc (gfc_find_derived_vtab): Fix up a stale
>>               non-use-associated duplicate vtab symbol.
>>               (gfc_is_finalizable): Same fix-up, for the finalizer wrapper
>>               symbol.
>>               * module.cc (read_module): Skip re-importing a symbol already
>>               visible via host association from the same module.
>>
>>       gcc/testsuite/ChangeLog:
>>
>>               PR fortran/126170
>>               * gfortran.dg/lto/pr126170_0.f90: New test.
>>               * gfortran.dg/lto/pr126170_1.f90: New test.
>> ---