This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/81093] [OOP] Accessing ranges of values in derived types leads to wrong result
- From: "janus at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 15 Jun 2017 20:26:28 +0000
- Subject: [Bug fortran/81093] [OOP] Accessing ranges of values in derived types leads to wrong result
- Auto-submitted: auto-generated
- References: <bug-81093-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81093
--- Comment #4 from janus at gcc dot gnu.org ---
(In reply to Dominique d'Humieres from comment #3)
> > ! wrong result
> > write(*,*) gen_data%mydata(:)%data1(1), gen_data%mydata(:)%data1(2)
>
> As said before I am not sure this is valid (a data_type2 object printed a
> data_type1 one).
I don't see why it would not be valid. data_type2 is an extension of
data_type1, so it certainly has both components, data1 and data2.
For an object which is declared as "class(data_type1)", you can always access
the data1 component without any problem, no matter if the dynamic type is
data_type1 or data_type2.
For the data2 component this is not the case. It is only present if the dynamic
type is data_type2 (or an extension of it), and you need a SELECT TYPE
statement to print it.
Does that alleviate your concerns or did I just not get your point?