Silverfrost Forums

Welcome to our forums

SCC compilation bug with multi-dimensional arrays

12 Mar 2017 9:37 #19079

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.

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;

>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
13 Mar 2017 8:07 #19090

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.

13 Mar 2017 10:49 #19093

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

13 Mar 2017 11:21 #19095

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.

17 Mar 2017 1:16 #19161

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?

17 Mar 2017 1:41 #19162

Yes I would persevere with SCC. After that I don' know.

18 Mar 2017 9:56 #19178

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.

Please login to reply.