This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC 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]

[Bug fortran/81093] [OOP] Accessing ranges of values in derived types leads to wrong result


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?

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