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

problem with conversion between variable kinds in fcompxe_2011.2.175

jim_cox
Beginner
428 Views
Hello again

I have just upgraded my compiler to w_fcompxe_2011.2.175 and its is giving me a bit of grief

In particular I'm having issues with implicit conversions between variable kinds

Here is an example - note that default integer is *2

INTEGER NLINK
INTEGER*4 IREC

NLINK = 20213

IREC = NLINK * 2

Gives IREC = -25110 . Although mathematically incorrect, I can understand why this is happening

But the previous version of the compiler I was using ( w_cprof_p_11.1.048 ) would result in IREC = 40426

Unfortunately we dont have the resources to track down and fix this issue right through our codebase (ancient and huge)

So is there a switch that forces fcompxe_2011.2.175 to behave as the older compiler?, or am I better to jusrt revert to the previous version?

Thankx

Jim


0 Kudos
2 Replies
Steven_L_Intel1
Employee
428 Views
Actually, the new result is correct. Looks like we fixed a bug. The expression NLINK * 2 is evaluated in INTEGER*2 and overflows. The hex representation of the result is 9DEA, which is -25110. This is then converted to INTEGER*4 for the assignment to IREC and you get -25110.

I tried the earliest 11.1 compiler I have handy, which is 11.1.067, and it also gave -25110. A result of 40426 would mean that the compiler incorrectly evaluated the expression.

There is no switch that reverses this, other than not using /integer_size:16.
0 Kudos
mecej4
Honored Contributor III
428 Views
The behavior that you ask for would violate the Fortran standard. If the 11.1.048 compiler did what you said it did, that was a bug, and you are asking for an option to reproduce the bug. I tried your example with the 8.1 compiler, with /integer_size:16, and the result was IREC = -25110.

I am curious to know what the resulting IREC would be if, instead of 20213, you used 32768.
0 Kudos
Reply