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

Internal Compiler Error with invalid access to POINTER and DLLIMPORT

danhoyt
Beginner
662 Views

I didn't report this through Premier Support because the root of this problem is a programming error, but I wanted to present it for Intel's consideration.

Here's a quick module for compiling (don't worry about linking):

SUBROUTINE BADRTN

IMPLICIT REAL*8 (A-H,O-Z)

COMMON/ A / AS

IF (AS(1).EQ.0) WRITE(*,*) 'BAD'

RETURN

END

Compiling this,I get "Error: This COMMON scalar or array is invalid in this context. [AS]" This is as expected.

However, I change it so the COMMON block holds a POINTER like so:

SUBROUTINE BADRTN

IMPLICIT REAL*8 (A-H,O-Z)

POINTER(ASPTR,AS)

COMMON/ A / ASPTR

IF (AS(1).EQ.0) WRITE(*,*) 'BAD'

RETURN

END

and it compiles okay with no error. Honestly, I would have thought I'd get something more like the first error.

Now I adda DLLIMPORT directive for the COMMON block:

SUBROUTINE BADRTN

IMPLICIT REAL*8 (A-H,O-Z)

!DEC$ ATTRIBUTES DLLIMPORT :: / A /

POINTER(ASPTR,AS)

COMMON/ A / ASPTR

IF ( AS(1).EQ.0) WRITE(*,*) 'BAD'

RETURN

END

andI get "Severe: **Internal compiler error: internal abort** Please report this error along with the circumstances in which it occurred in a Software Problem Report. Note: File and line given may not be explicit cause of this error."

If Iadd the DLLIMPORT directive to the original version, I still get the original error. So what's different when it's a POINTER?

-Dan Hoyt, Senior Systems Architect, Technology Service Corp, Colorado Operations

0 Kudos
2 Replies
Steven_L_Intel1
Employee
662 Views

First of all, Internal Compiler Errors should always be reported. Always. Even when triggered by a coding error. I'd appreciate it if you would do so. Please reference "T77302-CP".

In the second example, the compiler thinks that AS is a function since it is not declared or used in a context that prevents that (as in your first example.)

We have had bugs in the area of DLLIMPORT and pointers and you have found another one. Here's a workaround (though you probably intend to add an array declaration for AS somewhere...

SUBROUTINE BADRTN
IMPLICIT REAL*8 (A-H,O-Z)
!DEC$ ATTRIBUTES DLLIMPORT :: / A /
POINTER(TMP_ASPTR,AS)
INTEGER(INT_PTR_KIND()) ASPTR
COMMON/ A / ASPTR
TMP_ASPTR = ASPTR
IF (AS(1).EQ.0) WRITE(*,*) 'BAD'
RETURN
END
0 Kudos
danhoyt
Beginner
662 Views

Steve,

Reported, sir. Issue# 431880.

Yes, I did already work around it with a DIMENSION.

FYI, the reason I've structuredmy codein this rather obtuse way (both POINTER and DLLIMPORT)is to provide a means of memory sharing between C++ and Fortran with minimal impact to my legacy Fortran code. C++ owns the memory,I convert all myFortran COMMONs to POINTERs, then initialize the POINTERs at the beginning of my program. Speed impact is negligible, and the existing Fortransource doesn't really change beyond the COMMONs.

-Dan Hoyt

0 Kudos
Reply