- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In the code (that I try to attach, since it's about 200 lines), I am reading data from a file and experienced mysterious crashes.
In my reduced example, a line of data is like this :
20010101, 2.3456, 2222222.22#20010202, 2.0123, 2323232.32# !
Each line corresponds to one item of type T_LISTE, which contains a dynamic array of type T_VAL. Each T_VAL contains a date and two real values, separated by comma's in the file. The T_VAL's in the file are separated by "#".
Each line is read with a DT format, and the defined read for T_LISTE reads the line into a character variable, counts the "#" and then breaks the string up into parts that correspond to one T_VAL. That substring is then read, using a DT format for the date, as we have a user defined type to handle dates.
The crashes occur because of a behavior in the date type that I cannot explain.
In the module that defines the date type, I have :
type t_date integer :: j integer :: m integer :: a contains procedure :: r_fmt procedure, private, pass(expr) :: c_ass_d !<-- comment here procedure, private :: d_eq_d procedure, private :: d_ne_d generic :: read(formatted) => r_fmt generic :: assignment(=) => c_ass_d !<-- and comment here generic :: operator(==) => d_eq_d generic :: operator(/=) => d_ne_d end type t_date
On a read of a T_LISTE, the program tries to call c_ass_d (which assigns a date to a character variable) which than crashes because there is no character variable. If I comment the lines defining the assignment the code works as intended.
Of course our real types are much more complex than this, and I cannot remove the assignment of date to character. I do not understand however why the assignment is called in the first place.
As attached the code compiles with ifort 16.0.0.110. Version 15.0.4.0 shows the same behavior, however one has to remove "private" from the 3 bound procedures in t_date, as otherwise v15 throws an error.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks - this is strange. I don't think UDDTIO is relevant, but I passed along the whole test case to the developers. The issue ID is DPD200375613.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am going over all the problems I've submitted in the last years, and I think I have found this one to be an error in our code.
type t_date integer :: j integer :: m integer :: a contains procedure :: r_fmt procedure, private, pass(expr) :: c_ass_d !<-- comment here procedure, private :: d_eq_d procedure, private :: d_ne_d generic :: read(formatted) => r_fmt generic :: assignment(=) => c_ass_d !<-- and comment here generic :: operator(==) => d_eq_d generic :: operator(/=) => d_ne_d end type t_date
the lines "comment here" refer to a procedure that is supposed to handle an assignment like "character var = t_date var", with t_date on the RHS. However, we try to put this as a type bound procedure of t_date, and my reading of the standard tells me that this cannot be done, only assignments where t_date is on the LHS. c_ass_d must be put outside of the type t_date as a generic assignment.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page