This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch, Fortran, F03] PR 41106: Procedure Pointers with CHARACTER results


2009/8/21 Tobias Burnus <burnus@net-b.de>:
> When reading the patch, I was wondering about:
>
> ? ? ? /* Check character lengths if character expression. ?The test is only
> ? ? ? ? really added if -fbounds-check is enabled. ?*/
> - ? ? ?if (expr1->ts.type == BT_CHARACTER && expr2->expr_type != EXPR_NULL)
> + ? ? ?if (expr1->ts.type == BT_CHARACTER && expr2->expr_type != EXPR_NULL
> + ? ? ? ? && !expr1->symtree->n.sym->attr.proc_pointer
> + ? ? ? ? && !gfc_is_proc_ptr_comp (expr1, NULL))

Why were you wondering about this? Is there something wrong with it?


> I therefore created the following test case, which should print a
> run-time error message, but all I got is an ICE:
>
> aa.f90:23:0: internal compiler error: in gfc_trans_pointer_assignment,
> at fortran/trans-expr.c:4243

Hm, funny. I don't get that ICE with r150967 plus my patch (2nd
version). And I *do* get the run-time error message:

Fortran runtime error: Unequal character lengths (3/2) in pointer assignment


Since you approved the patch, I will go on and commit it. If there is
a problem with -fcheck=bounds, we can still fix it later.


Cheers,
Janus



> ! { dg-do run }
> ! { dg-options "-fcheck=all" }
> implicit none
> character(len=3), pointer :: ptr
> procedure(f),pointer :: pptr
>
> ! Invalid & detected
> !ptr => f(2)
> ! Fortran runtime error: Unequal character lengths (3/2)
> ! ? ? ? ? ? ? ? ? ? ? ? ?in pointer assignment
>
> pptr => f ! Gives an ICE
>
> ! Invalid:
> ptr => pptr(2)
> ! Should give same RT error
> contains
> ?function f(i)
> ? ?integer,intent(in) :: i
> ? ?character(len=i), pointer :: f
> ? ?allocate(f)
> ?end function f
> end
>
>
>
> Tobias
>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]