- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I can see your point on this issue.
-check format
will catch this sort of mismatch. This runtime check is not on by default but can be enabled with the option above.
Let me talk to the developers on this one. Perhaps we can improve this.
ron
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I suspect the reason why this is not enabled by default, is that there is no way to check the input at compile time, and to check it at runtime requires linking against additional libraries and executes additional code, which has the potential to slow the program down. Enabling it by default would be a headache to most other users for this reason.
FWIW, I always compile with -warn (compile time warnings) and -traceback (very low expense to get call stack traces when something goes wrong) and the first time I run the code after editing/modifying/writing it, I enable all runtime checks with -check.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Izaak Beekman wrote:
...
FWIW, I always compile with -warn (compile time warnings) and -traceback (very low expense to get call stack traces when something goes wrong) and the first time I run the code after editing/modifying/writing it, I enable all runtime checks with -check.
Excellent suggestions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It is our extension that we allow free conversion among numeric types in formatted, list-directed and NAMELIST input. As Ron says, we have an option to disable this extension. The words in the standard are a requirement on the program, not the compiler. As Izaak says, this rule can't be checked at compile time.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Steve Lionel (Intel) wrote:I am not sure to understand this point. Do you say that what I consider as a bug is a desired feature (extension) with a real use-case?
It is our extension that we allow free conversion among numeric types in formatted, list-directed and NAMELIST input.
Steve Lionel (Intel) wrote:I also speak about the program behavior, i.e. checking the format and variable match at run-time. FYI, gfortran performs this test by default, so that my end-users experience is better/correct with gfortran (comprehensive error) than ifort (invalid result)...
As Ron says, we have an option to disable this extension. The words in the standard are a requirement on the program, not the compiler. As Izaak says, this rule can't be checked at compile time.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
On reconsideration, this is probably not intentional. I was thinking of something different. Let me investigate further.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ok, here's what's going on. This is intentional behavior. The primary motivation was to support pre-F77 code that, typically, stored character data in numeric variables, reading and writing with A format. Curiously, while the standard is explicit in saying that the datatype "shall" be integer for I format, "shall" be real or complex for F,E,D,EN,ES, "shall" be logical for L, the word "shall" is not there for A format.
What we do here is read in the value as an integer and then store it to the variable as if it were an integer. For smaller integer values, this tends to end up looking like a denormalized real value. Correspondingly, on a write, we interpret the bits as an integer (for I format).
This extension is decades old and my guess is that the developers at the time chose to be "generous" in allowing mismatches, especially as programs of the time tended to do lots of weird things with mismatched types. It's a situation that has outlived its usefulness.
I have entered a feature request, issue DPD200361091, recommending that the default be changed to -check format so that these mismatches will be detected. Users who want to use the extension can restore the old behavior with -check noformat.
This is another example of compilers with a long history being more flexible than newer compilers that didn't grow up with very old programs.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Steve Lionel (Intel) wrote:Ok, I suspected something like this.
Ok, here's what's going on. This is intentional behavior. The primary motivation was to support pre-F77 code that, typically, stored character data in numeric variables, reading and writing with A format. Curiously, while the standard is explicit in saying that the datatype "shall" be integer for I format, "shall" be real or complex for F,E,D,EN,ES, "shall" be logical for L, the word "shall" is not there for A format. What we do here is read in the value as an integer and then store it to the variable as if it were an integer. For smaller integer values, this tends to end up looking like a denormalized real value. Correspondingly, on a write, we interpret the bits as an integer (for I format).
Steve Lionel (Intel) wrote:Indeed. Thank you Steve for this detailed analysis and future "improvement". For now I will enable "-check format" for my current version of ifort.
This extension is decades old and my guess is that the developers at the time chose to be "generous" in allowing mismatches, especially as programs of the time tended to do lots of weird things with mismatched types. It's a situation that has outlived its usefulness. I have entered a feature request, issue DPD200361091, recommending that the default be changed to -check format so that these mismatches will be detected. Users who want to use the extension can restore the old behavior with -check noformat. This is another example of compilers with a long history being more flexible than newer compilers that didn't grow up with very old programs.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page