Silverfrost Forums

Welcome to our forums

Illegal memory reference

9 Aug 2006 11:48 #914

I am trying to compile the XML library just released at http://www.uszla.me.uk/software/FoX.html

During the compile of the file m_common_attrs.f90, I get the following compile warnings and errors:

ftn95 m_common_attrs.f90 /mod_path ..\..\libs /persist

[FTN95/Win32 Ver. 4.9.0 Copyright (C) Silverforst Ltd 1993-2005] PROCESSING MODULE [<M_COMMON_ATTRS> FTN95/Win32 v4.9.0] NO ERRORS [<NUMBER_OF_ENTRIES> FTN95/Win32 v4.9.0] 0104) function has_key(dict,key) result(found) *** Illegal memory reference 1 ERROR [<HAS_KEY> FTN95/Win32 v4.9.0] 0120) pure function get_key_index(dict,key) result(ind) *** Illegal memory reference 1 ERROR [<GET_KEY_INDEX> FTN95/Win32 v4.9.0] 0136) function get_value_by_key(dict,key,status) result(value) *** Illegal memory reference 1 ERROR [<GET_VALUE_BY_KEY> FTN95/Win32 v4.9.0] NO ERRORS [<REMOVE_KEY_BY_INDEX> FTN95/Win32 v4.9.0] NO ERRORS [<GET_VALUE_BY_INDEX> FTN95/Win32 v4.9.0] NO ERRORS [<GET_KEY> FTN95/Win32 v4.9.0] NO ERRORS [<ADD_ITEM_TO_DICT> FTN95/Win32 v4.9.0] NO ERRORS [<ADD_KEY_TO_DICT> FTN95/Win32 v4.9.0] NO ERRORS [<ADD_VALUE_TO_DICT> FTN95/Win32 v4.9.0] NO ERRORS [<SET_NSURI_BY_INDEX> FTN95/Win32 v4.9.0] NO ERRORS [<SET_PREFIX_BY_INDEX> FTN95/Win32 v4.9.0] NO ERRORS [<SET_LOCALNAME_BY_INDEX_S> FTN95/Win32 v4.9.0] NO ERRORS [<SET_LOCALNAME_BY_INDEX_VS> FTN95/Win32 v4.9.0] NO ERRORS [<GET_NSURI_BY_INDEX> FTN95/Win32 v4.9.0] NO ERRORS [<GET_PREFIX_BY_INDEX> FTN95/Win32 v4.9.0] NO ERRORS [<GET_LOCALNAME_BY_INDEX> FTN95/Win32 v4.9.0] NO ERRORS [<GET_NSURI_BY_KEYNAME> FTN95/Win32 v4.9.0] NO ERRORS [<GET_PREFIX_BY_KEYNAME> FTN95/Win32 v4.9.0] NO ERRORS [<GET_LOCALNAME_BY_KEYNAME> FTN95/Win32 v4.9.0] NO ERRORS [<INIT_DICT> FTN95/Win32 v4.9.0] NO ERRORS [<RESIZE_DICT> FTN95/Win32 v4.9.0] NO ERRORS [<DESTROY_DICT> FTN95/Win32 v4.9.0] NO ERRORS [<RESET_DICT> FTN95/Win32 v4.9.0] NO ERRORS [<PRINT_DICT> FTN95/Win32 v4.9.0] NO ERRORS [<PARSE_STRING_TO_DICT> FTN95/Win32 v4.9.0] NO ERRORS [<M_COMMON_ATTRS> FTN95/Win32 v4.9.0] *** Compilation failed

Is this a compiler error?

10 Aug 2006 4:22 #915

Charles

It looks like a compiler bug. Can you isolate the fault into a few lines and post the code here?

11 Aug 2006 11:07 #921

Sample code which causes the illegal memory reference is as follows:

module attrs type dict_item character(len=1), pointer, dimension(:) :: key end type dict_item contains function str_vs(vs) result(s) character, dimension(:), intent(in) :: vs character(len=size(vs)) :: s s = transfer(vs,s) end function str_vs function has_key(dict,key) result(found) type(dict_item), intent(in) :: dict character(len=*), intent(in) :: key logical :: found found = ( key == str_vs(dict%key) ) end function has_key end module attrs

I believe it is associated with the line ' found = ( key == str_vs(dict%key) )'. If this is replaced by ' key = str_vs(dict%key)' with key changed to intent(inout) then the error disappears.

15 Aug 2006 2:08 #927

Charles

I have only had a brief look at this and I hope to investigate further however...

This is a compiler bug and on my machine it is restricted to .NET. At this stage I am not sure what the code should be doing and it is possible that there are programming errors in the code. You could check this out by running in Win32 mode and using the debugger. Even if there are programming errors the compiler should report a sensible failure message under .NET.

When you check this out I suggest that you pay particular attention to the TRANSFER function to make sure that it is doing what you expect (is it moving a character variable into a character array?).

15 Aug 2006 6:43 #930

Paul,

I'm only compiling in win32 mode as I don't have the .NET environment installed on my machine.

I'm really not sure myself what the code is doing as I extracted this from a recently released Fortran XML library (called FoX). The TRANSFER function moves a character array into a character scalar, which is legal under F95 rules (I think).

The code compiles using the Intel v9.1 compiler, and has been compiled and tested on other compilers - I'm not sure whether it makes it correct, though.

regards

Charles

15 Aug 2006 11:51 #932

Charles

What version of FTN95 are you running?

15 Aug 2006 5:05 #935

Paul,

I am currently running ver 4.9.0.

When compiling at the command line I get the error in Win32 mode (compiler options in Effect are COLOUR DELETE_OBJ_ON_ERROR LIST MINIMISE_REBUILD NO_QUIT NON_STANDARD SINGLE_THREADED. With /checkmate (Win32 mode) the error does not occur. With /clr (.NET mode) the error occurs.

The /checkmate is not a universal panacea: when I added this to the compiler options for the unedited source, the illegal memory reference still occurred - I shall have to generate a new example.

The following snippit may be relevant. If I compile the following

module vs contains function vs_str(s) result(vs) character(len=*), intent(in) :: s character, dimension(len(s)) :: vs vs = transfer(s, vs) end function vs_str end module vs

I get the warning

[FTN95/Win32 Ver. 4.9.0 Copyright (C) Silverforst Ltd 1993-2005] PROCESSING MODULE [<VS> FTN95/Win32 v4.9.0] 0003) function vs_str(s) result(vs) WARNING - In a call to VS_STR from another procedure, the first argument was of type CHARACTER(LEN=*), it is now INTEGER(KIND=3) NO ERRORS, 1 WARNING [<VS_STR> FTN95/Win32 v4.9.0] NO ERRORS [<VS> FTN95/Win32 v4.9.0]

The warning seems to be in error. It only occurs if the function is wrapped in a module.

17 Aug 2006 1:19 #938

Charles

This bug has now been fixed for the next release. In fact it had already been fixed for Win32 and we have now fixed it for .NET. The Win32 fix was not included in the 4.91 patch. Both fixes will be in the next release.

Please login to reply.