Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29263 Discussions

error #6258: The CHARACTER string result is greater than 7198 characters.

DataScientist
Valued Contributor I
826 Views

I have the following code

integer :: iostat
logical :: exist = .false.
character(*), parameter :: path = repeat("A", 10000)
!character(:), allocatable :: path; path = repeat("A", 10000)
inquire(file = path, exist = exist)
print *, exist
end

which yields the following error:

error #6258: The CHARACTER string result is greater than 7198 characters.

Is this error reflecting the standard Fortran programming language limitation, or is it an ifort / ifx limit? If it is a compiler limitation, then why?
In any case, the error can be resolved by letting `path` be allocatable. But even then, we hit another compiler warning (which used to be an error in my older tests).

forrtl: warning (785): File-path is longer than Intel(r) Fortran limit of 4096

 Again why?

If I supply the `iostat` as an argument to `inquire()`, then I get a non-zero error code `785` which indicates the occurrence of an error. Then again, why is it a warning (which, as far as I remember, used to be an actual runtime error not long ago, perhaps with older ifort compilers) with the status code but turns into an error with the error code supplied? Isn't it a dangerous behavior by the compiler?

0 Kudos
1 Solution
Steve_Lionel
Honored Contributor III
801 Views

Intel Fortran has a 7198 character limit for character constants - see Compiler Limits

I'm not sure where the 4096 character limit on a file specification comes from, though Windows tends to limit file paths to 260 characters, with some exceptions. I do see this warning documented, but am uncertain why it is a warning and where the number comes from.

What are you trying to accomplish here?

View solution in original post

3 Replies
Steve_Lionel
Honored Contributor III
802 Views

Intel Fortran has a 7198 character limit for character constants - see Compiler Limits

I'm not sure where the 4096 character limit on a file specification comes from, though Windows tends to limit file paths to 260 characters, with some exceptions. I do see this warning documented, but am uncertain why it is a warning and where the number comes from.

What are you trying to accomplish here?

DataScientist
Valued Contributor I
781 Views

Thanks, Steve; I had documented this behavior as an oddity in the codebase.
I noticed this issue when the program passed a long string to `inquire(..., iostat = iostat)`.
Because Intel ifort/ifx returns a non-zero `iostat` for this warning, the program stops with an error message.

It seems like this is a compiler limitation. To bypass it, we have now wrapped `inquire()` with another function that first checks for the string length to be less than 256/4096 on Windows/Linux.

However, ifort/ifx's flagging of this behavior as an error when `iostat` is passed is a significant problem. It must be either a warning or an error, not both, depending on the presence of `iostat`. This makes reliable capturing of other errors more complex, as in the solution above.

0 Kudos
Steve_Lionel
Honored Contributor III
726 Views

IOSTAT doesn't have the concept of "warning". My view is that it is a bug to call it a warning. If it still works, let it succeed; if it fails, call it an error. I'd love to see an explanation from Intel development on this topic. 

Reply