Re: PR Fortran/91960 Patch
Steve Kargl <[email protected]>
| Newsgroups | gmane.comp.gcc.patches,gmane.comp.gcc.fortran |
|---|---|
| Message-ID | <[email protected]> |
On Mon, Jan 12, 2026 at 09:48:56AM -0800, Jerry D wrote: > On 1/11/26 12:33 PM, Steve Kargl wrote: > > The attach patch fixes PR Fortran/91960. This PR is another > > one from Gerhard in 2019-10.01. A patch has been lingering > > in the PR since 2023-05-30. > > > > The patch checks that an array constructor in a parameter > > statement is in fact a constant expression. I'll note > > that the patch requires a special carve out to accommodate > > the fix for Fortran/117070. > > > > 2026-01-11 Steven G. Kargl <[email protected]> > > > > PR Fortran/91960 > > * resolve.cc (resolve_fl_parameter): Check the righthand symbol > > is a constant expression. > > > > 2026-01-11 Steven G. Kargl <[email protected]> > > > > PR Fortran/91960 > > * gfortran.dg/pr69962.f90: Adjust testcase to ignore new error message. > > * gfortran.dg/pr91960_1.f90: New test. > > * gfortran.dg/pr91960_2.f90: Ditto. > > > > I am wondering about the comment: > > + /* PR fortran/117070 argues a nonconstant proc pointer can appear in > + the array constructor of a paramater. I don't buy it, but... */ > + if (sym->value->ts.type == BT_DERIVED > + && sym->value->ts.u.derived > + && sym->value->ts.u.derived->attr.proc_pointer_comp) > + return true; > + gfc_error ("Expecting constant expression near %L", &sym->value->where); > + return false; > > It either is allowed or it is not. Do we need to review the Standard to > confirm or deny this? > It's probably easier to go see the audit in fortran/117070. Here's a chopped down version of that PR. module funcs implicit none abstract interface function retchar() character(len=1) :: retchar end function end interface contains function a() character(len=1) :: a a = 'a' end function end module module dispatch_table use funcs implicit none private public :: table public :: build_table, pc ! Procedure container type :: pc procedure(retchar), pointer, nopass :: rc => null() end type ! Static dispatch table type(pc), parameter :: table(3) = [pc(a)] ! Doesn't work end module The fix for 117070 accepts the line marked '! Doesn't work'. The argument in that PR is that pc(a) is a constant expression. I don't see how the address of function can be considered a constant expression; in particular, some OS's support address relocation and randomization. -- Steve