View previous topic :: View next topic |
Author |
Message |
Ryan
Joined: 25 Feb 2016 Posts: 110
|
Posted: Sun Mar 12, 2017 10:37 am Post subject: SCC compilation bug with multi-dimensional arrays |
|
|
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 |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7916 Location: Salford, UK
|
Posted: Mon Mar 13, 2017 9:07 am Post subject: |
|
|
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 |
|
|
Ryan
Joined: 25 Feb 2016 Posts: 110
|
Posted: Mon Mar 13, 2017 11:49 am Post subject: |
|
|
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 |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7916 Location: Salford, UK
|
Posted: Mon Mar 13, 2017 12:21 pm Post subject: |
|
|
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 |
|
|
Ryan
Joined: 25 Feb 2016 Posts: 110
|
Posted: Fri Mar 17, 2017 2:16 pm Post subject: |
|
|
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 |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7916 Location: Salford, UK
|
Posted: Fri Mar 17, 2017 2:41 pm Post subject: |
|
|
Yes I would persevere with SCC. After that I don' know. |
|
Back to top |
|
|
Ryan
Joined: 25 Feb 2016 Posts: 110
|
Posted: Sat Mar 18, 2017 10:56 pm Post subject: |
|
|
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 |
|
|
|