[Bug fortran/71723] [5/6/7 Regression] [F08] ICE on invalid pointer initialization
janus at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Fri Nov 18 14:29:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71723
--- Comment #5 from janus at gcc dot gnu.org ---
(In reply to Walter Spector from comment #0)
>
> type(data_t), pointer :: data
> integer, pointer :: idata => data%i
Thinking about it some more, I'm actually not sure why this should be illegal.
It's certainly true that 'data' itself does not have the TARGET attribute. But
the thing that 'data' points to (whatever it is) certainly must be a TARGET,
otherwise 'data' couldn't point to it, right?
[Side note: There is actually a runtime problem with your test case, since
'data' is not associated. But we probably don't need to detect this at compile
time.]
To clarify my point, let me give you an expanded example, which I think is
valid and runs nicely with gfortran:
program p
implicit none
type data_t
integer :: i = 9
end type
type(data_t), target :: d
type(data_t), pointer :: dp
integer, pointer :: ip
dp => d
ip => d%i ! certainly legal
ip => dp%i ! also legal!?!
print *,ip
end
If you agree that this is valid, the original code in comment 0 should also be
valid, I think.
More information about the Gcc-bugs
mailing list