Silverfrost Forums

Welcome to our forums

Need help interpreting this compiler warning, please!

26 Jun 2006 7:17 #795

This is the separate post referred to in the post about 'mixed' projects ...

When I compiled my code using Checkmate, just to reassure myself that the array overrun would indeed have been caught, at runtime if not at compile time, the compiler threw up this warning which generated a nasty sinking feeling in my innards:

'warning 362 - Assigning a value of type CHARACTER(LEN=1) to a variable of type INTEGER(KIND=3) is a non-standard extension, use the TRANSFER intrinsic'

The sinking feeling is for three reasons:

  1. The line in question is deep inside the core of my code, and I had not been aware there was an issue with it until now.
  2. I can't understand the warning: I can't see an assignment of a value of type character (len=1) to a variable of type integer (kind=3)
  3. From my perspective, the TRANSFER intrinsic is not far removed from black magic. I've managed without it so far, and I would have been happier to keep things that way 😦

The line in question and the declarations that relate to it are:

  type rgbint
    integer redint
    integer greint
    integer bluint
  end type rgbint

  type (rgbint) ... pixsin

  integer  ... ptrs, ...

  pixsin = rgbint (ichar (ccore1 (ptrs + 2)), ichar (ccore1 (ptrs + 1)), ichar (ccore1 (ptrs)))

Now then.

  • ccore1 returns a single character from an integer (kind=3) memory location. I know it's an extension;
  • ichar converts a character to an integer, of default type

So where is a value of type character (len=1) being assigned to a variable of type integer (kind=3)? And how would I achieve what this non-standard statement does using the standard intrinsic TRANSFER?

26 Jun 2006 9:13 #799

Andy

The warning is relatively new and it looks like it is a false warning in this case.

The intention was to issue the warning for the following:

INTEGER i i = 'F'

which compiles and runs but is probably not what the programmer intended.

In your code, if the values are what you expect then you can safely ignore the warning.

27 Jun 2006 1:13 #803

That's reassuring. The only follow-up question it prompts is this: the statement in my code which generates the false warning does contain the non-standard function ccore1, to extract one character of data from a given address. All things being equal, I'd prefer not to have to use non-standard functions - but am I right in thinking that there is still no standard way in FORTRAN 95 to extract data from a given address? So in particular there is no voodoo way to do it using TRANSFER?

27 Jun 2006 4:35 #807

Andy

Yes you are right. If there is a way then I do not know what it is.

Please login to reply.