Showing results for 
Search instead for 
Did you mean: 
New Contributor II

Compiled binary file containing a version number has problem in XE 2016 64 bit

Our developers compile the exe rather than having a commit process do if for us. The exe contains a template function to return a version number. The binary then gets edited externly by our commit process once regression tests pass.

But on upgrading to 2016 the binary file no longer contains the template string in 64 bit version. I have optimization dissabled for the source for the template function and even used the volatile keyword to indicate to the compiler to do optimising.

Here is the code:

module getVersionStringMod
implicit none


function getVers() result(aString)
   character(:), allocatable :: aString
   integer i
#ifndef DEBUG
   character(35), volatile :: buildVersion
#ifdef DEBUG
   aString(1:1) = 'D'
   aString(2:2) = 'E'
   aString(3:3) = 'B'
   aString(4:4) = 'U'
   aString(5:5) = 'G'
   do i = 6, 20
      aString(i:i) = ' '
   end do
   buildVersion = '$Revision:: 0.0                  $'C
   do i = 1, 20
      aString(i:i) = buildVersion(12+i:12+i)
   end do
end function

end module

The external editor looks for string

'$Revision:: 0.0                  $'

But instead the binary contains:

'$Revisio odd chars here I could not include in post n:: 0.0                $'

Does the compiler now do some deliberate obfuscation ?


0 Kudos
1 Reply

Very interesting. What happens is that the compiler does the assignment in pieces with integer move instructions. The source string therefore doesn't have to be contiguous in the object file.

What you want instead is to use an initialization for buildVersion like so:

   character(35), volatile :: buildVersion = '$Revision:: 0.0                  $'C

This will keep it all in one piece.

0 Kudos