https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123782

--- Comment #18 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
On Mon, Jan 26, 2026 at 05:45:48PM +0000, jvdelisle at gcc dot gnu.org wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123782
> 
> --- Comment #17 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
> nagfor accepts it.
> 

(code removed)

> $ nagfor pr123782.f90 
> NAG Fortran Compiler Release 7.2(Shin-Urayasu) Build 7238
> Questionable: pr123782.f90, line 22: Variable B set but never referenced
> [NAG Fortran Compiler normal termination, 1 warning]
> $ ./a.out 
>    1.0000000   1.0000000   1.0000000   1.0000000   1.0000000
> $ 
> 
> I suggest you cleanup the patch and post a changelog Steve.
> 

The current patch is incorrect as Harald pointed out.  I think
I can come up with a special case to allow Ivan's code, but
wonder if we need to deal with some deeper structure construction
and try to locate the rightmost part-ref.  In quickly written
(and likely wrong) code

type (a_t)
   real x
end type a_t

type (b_t)
   type (a_t) a(4)
end type (b_t)

type(b_t), contiguous, target :: b(:)
real, pointer, contiguous :: x(:)

allocate(b(3))
b%a%x = 1
x => b%a%x

I would need to revisit pointer assignment in the Fortran
standard.

Reply via email to