forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

SCC compilation bug with multi-dimensional arrays

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> 64-bit
View previous topic :: View next topic  
Author Message
Ryan



Joined: 25 Feb 2016
Posts: 26

PostPosted: Sun Mar 12, 2017 10:37 am    Post subject: SCC compilation bug with multi-dimensional arrays Reply with quote

SCC 3.88 fails to compile the following code with errors reported of 'Can't complete RBP relative address' when accessing global multi-dimensional arrays for 64 bit compilation. There are two workarounds, also shown in the code snippet which compile OK.

Code:
int two_dimensional_array[4][3];

void initialise_array() {
   for (int i = 0; i < 4; i++) {
      two_dimensional_array[i][0] = 0;
      two_dimensional_array[i][1] = 0;
      two_dimensional_array[i][2] = 0;
   }
}

// Workaround by gaining a pointer to the array row, less readable.
void initialise_array_workaround() {
   for (int i = 0; i < 4; i++) {
      int *array_row = two_dimensional_array[i];

      array_row[0] = 0;
      array_row[1] = 0;
      array_row[2] = 0;
   }
}

// Workaround to pass global as a parameter, better practice anyway.
void alt_initialise_array(int x_dimensional_array[4][3]) {
   for (int i = 0; i < 4; i++) {
      x_dimensional_array[i][0] = 0;
      x_dimensional_array[i][1] = 0;
      x_dimensional_array[i][2] = 0;
   }
}

int main()
{
   alt_initialise_array(two_dimensional_array);
   return 0;
}


The compilation command and compiler output;
Code:
>scc arrayrepro /win/64
[Silverfrost SCC/WIN32 Ver 3.88 Copyright (c) Silverfrost Ltd 2017]
   0011   void initialise_array_workaround() {
*** Can't complete RBP relative address
*** Can't complete RBP relative address
*** Can't complete RBP relative address
    3 ERRORS  [<ARRAYREPRO> SCC/WIN32 Ver 3.88]
*** Compilation failed
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 4919
Location: Salford, UK

PostPosted: Mon Mar 13, 2017 9:07 am    Post subject: Reply with quote

Thanks for the feedback.

By way of explanation, 64 bit SCC is an unfinished and largely untested product. In other words is it a pre-beta release. If used, it should be treated with extra caution. This "error" report appears to refer to part of the unfinished work.
Back to top
View user's profile Send private message
Ryan



Joined: 25 Feb 2016
Posts: 26

PostPosted: Mon Mar 13, 2017 11:49 am    Post subject: Reply with quote

Understood.

Considering that, do you have any advice on our options for the following?

We have a 32 bit app composed of Fortran and C++ code. We currently use C++ / ClearWin for the UI and Fortran for the back end. The .F90 and .CPP are linked together to produce a single executable.

We are attempting to create a 64 bit release of the code. Do you think SCC 64 will work (with some possible workarounds for compilation)?

If not I can only see one option, to try and split the C++ / Fortran into an exe (compiled with MSVC) and a DLL (from FTN95).

Thanks in advance
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 4919
Location: Salford, UK

PostPosted: Mon Mar 13, 2017 12:21 pm    Post subject: Reply with quote

Is the ClearWin+ code written in Fortran? I am not sure if it makes a difference but it would help me to work out your options.
Back to top
View user's profile Send private message
Ryan



Joined: 25 Feb 2016
Posts: 26

PostPosted: Fri Mar 17, 2017 2:16 pm    Post subject: Reply with quote

Sorry for the slow response Paul, I didn't see your reply.

The ClearWin+ code is in both C++ and Fortran.

The only option I can see is to try and see if SCC does the job and if not, split the C++ to an EXE that is compiled by MSVC and compile the Fortran code into a DLL. All of the code was compiled into a single EXE previously.

Then I can statically link them via the MSVC compiler.

Does that sound workable?
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 4919
Location: Salford, UK

PostPosted: Fri Mar 17, 2017 2:41 pm    Post subject: Reply with quote

Yes I would persevere with SCC. After that I don' know.
Back to top
View user's profile Send private message
Ryan



Joined: 25 Feb 2016
Posts: 26

PostPosted: Sat Mar 18, 2017 10:56 pm    Post subject: Reply with quote

It seems SCC is not complete in 64 bit compilation mode and not stable enough to create 64 bit C object files. I've come across quite a few 'todo' style of messages output by the compiler so I've not got any confidence that the output will indeed work on a large project. Plus there are a lot of memory access faults during compilation.

I'll rework it with MSVC and link the two files statically using SLINK64.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> 64-bit All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group