- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Following program: program bsccbroken write(*,*) '\"ABCDEF\"' write(*,*) '\"ABCDEF\"\0' write(*,*) '\"#\"' write(*,*) '\"#\"\0' end program bsccbroken
When compiled with ifort version 15.0.2:
ifort -assume bscc -warn all -g -o bscc bscc.f
Produces following output:
[bma@localhost f]$ ./bscc
"ABCDEF"
"ABCDEF
"#"
"#
Please notice that closing quote is not included when \0 is appended to the end of the string. I work with large legacy code base where those closing zero bytes (\0) are very often included to ensure interoperability with C APIs.
While using IBM fortran xlf90 produces expected result:
$ xlf90 -o bscc bscc.f
** bsccbroken === End of Compilation 1 ===
1501-510 Compilation successful for file bscc.f.
$ ./bscc
"ABCDEF"
"ABCDEF"
"#"
"#"
Is it well known problem with -assume bscc option? Is there a patch for this? Is this behavior different in newer versions of Composer Studio?
Thanks in advance for any information.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The problem here is that Intel Fortran doesn't recognize \" as a valid escape sequence (reference). The manual says:
If a string contains an escape sequence that isn't in this table, the backslash is ignored.
I admit it is a bit weird that it throws away the \0 in this case - that may be a bug in itself. If you don't have any unrecognized sequences, then \0 is processed properly.
I was able to reproduce this behavior in 19.0.5.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for your response. For the time being I fixed the application code by removing redundant backslash before ".
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page