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

mixed relational expression

tracyx
New Contributor I
640 Views
ifort (11.0.083) compiles without error if I have a mixed relational expression of the form,

if ('abc'==5) then...

how does ifort treat such expressions? i could not find any discussion in the documentation. should this raise an error?
0 Kudos
1 Solution
Steven_L_Intel1
Employee
640 Views
It's historical. For character literals 4 characters or less they are treated as if they were Hollerith constants (e.g. 3Habc), which are integers.

View solution in original post

0 Kudos
4 Replies
TimP
Honored Contributor III
640 Views
Quoting - tracyx
ifort (11.0.083) compiles without error if I have a mixed relational expression of the form,

if ('abc'==5) then...

how does ifort treat such expressions? i could not find any discussion in the documentation. should this raise an error?
Apparently, 'abc'==5 is evaluated to .false. at compile time. If you set -stand, you get the mandatory warning according to standard (at least in current versions). This is a weird extension, not supported by many other compilers.
0 Kudos
tracyx
New Contributor I
640 Views
Quoting - tim18
Apparently, 'abc'==5 is evaluated to .false. at compile time. If you set -stand, you get the mandatory warning according to standard (at least in current versions). This is a weird extension, not supported by many other compilers.

Thank you for your reply. I had some code which had an expression like this (in error), and only spotted it when I ran it through g95.

This seems a bizarre (and potentially dangerous) extension. Apparently 'abc'>5 is true for some reason.
0 Kudos
Steven_L_Intel1
Employee
641 Views
It's historical. For character literals 4 characters or less they are treated as if they were Hollerith constants (e.g. 3Habc), which are integers.
0 Kudos
TimP
Honored Contributor III
640 Views
It's historical. For character literals 4 characters or less they are treated as if they were Hollerith constants (e.g. 3Habc), which are integers.
Compilers I used in the past went the other way, treating Holleriths as CHARACTER, in contexts where they weren't permitted in f66, and so aren't covered by standards.
0 Kudos
Reply