Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!
26742 Discussions

Missing error when using a non-TARGET variable in C_LOC

ereisch
Novice
168 Views

When using C_LOC from ISO_C_BINDING, the standard states that items passed to C_LOC() must have the TARGET attribute.  However, when I pass in a simple BYTE variable from a COMMON structure, the compiler does not produce any warnings or errors as would be expected.

 BYTE START_ADR, END_ADR
 STRUCTURE    /TEST/
    COMPLEX*8 SOME_VAL1
    REAL*4 SOME_VAL2
 END STRUCTURE

 RECORD /TEST/ FOO

 COMMON/CTEST/
& START_ADR(8),
& FOO(10000),
& END_ADR(4)

If I create a line with C_LOC( START_ADR ), ifort treats it as valid, but gfortran reports it as a violation of the standard.  Intel's documentation on C_LOC seems to suggest it should be illegal as well unless I provide "TARGET START_ADR, END_ADR" somewhere after the variable definition.

Additionally (unrelated topic), in my implementation, I also define VOLATILE CTEST, but the standard suggests VOLATILE can only be defined on variables, not common definitions.

0 Kudos
2 Replies
andrew_4619
Honored Contributor I
149 Views
This already has a thread from 28/11/2020
andrew_4619
Honored Contributor I
127 Views

https://community.intel.com/t5/Intel-Fortran-Compiler/Stand-C-LOC-and-Target-Attribute/m-p/1232351#M...

The above was the topic link. A support ticket was raised. I am not sure about the VOLATILE which is a different topic as you note. Given your code has non-standard constructs I would think you are not using standards checking.  Intel could thus accept non-standard usage as an language extension. You would need to make an otherwise conforming test case I think. 

Reply