Silverfrost Forums

Welcome to our forums

Scc 64 bit: /debug error + erroneous warnings

15 Jul 2020 8:46 #26004

In many Fortran apps we make calls to C/C++ and hence make use of scc 64 bit.

Compiling the following C code for 64 bit (named wrong_warning.cpp) produces erroneous warnings and results in an error if specifiying scc option /debug:

#include <stdio.h>
#include <string.h>
int main(int argc,char *argv[]) {
    int j=0;
    printf('argc=%d\n',argc);
    if (argc > 1) {
      printf('argv[1]=%s\n',argv[1]);
    } else {
      printf('No parameter specified ... exiting\n');
      return 1;
    }
    if( strcmp(argv[1],'point') == 0 )
      j=1;
    else if(strcmp(argv[1],'polygon') == 0 )
      j=2;
    else
      j=3;
    printf('Case=%d\n',j);
    return 0;
}

Command

scc wrong_warning.cpp /link /64

displays warnings

[Silverfrost SCC/WIN32 Ver 4.31 Copyright (c) Silverfrost Ltd 2
   0009         printf('No parameter specified ... exiting\n');
WARNING - This statement will never be executed
   0012       if( strcmp(argv[1],'point') == 0 )
WARNING - This statement will never be executed
   0014       else if(strcmp(argv[1],'polygon') == 0 )
WARNING - This statement will never be executed
   0017         j=3;
WARNING - This statement will never be executed
    NO ERRORS, 4 WARNINGS  [<WRONG_WARNING> SCC/WIN32 Ver 4.31]
[SLINK64 v2.14, Copyright (c) Silverfrost Ltd. 2015-2020]
Loading c:\ds\samples\salford_8.40\lgotemp@.OBJ
Creating executable file WRONG_WARNING.EXE

which are not true. This may be shown via commands

wrong_warning.exe
wrong_warning.exe point
wrong_warning.exe point1

Moreover, adding option /debug to the scc command mentioned above in order to produce a 64 bit debuggable exe file results in an error and does not create an exe file:

c:\ds\samples\salford_8.40>scc wrong_warning.cpp /link /64 /debug
[Silverfrost SCC/WIN32 Ver 4.31 Copyright (c) Silverfrost Ltd 2020]
   0020   }
*** Attempt to emit 32-bit instruction in /64 mode
    1 ERRORS  [<WRONG_WARNING> SCC/WIN32 Ver 4.31]
*** Compilation failed

If omitting option /64 and thus creating the corresponding 32 bit versions these phenomenons do not occur.

Regards, Dietmar

15 Jul 2020 10:08 #26005

Dietmar

Thank you for the feedback. However, 64 bit SCC still has the status of being unsupported. These issues are known and will need to be fixed before changing the status of SCC. In the meantime it may be possible to fix some bugs if they are blocking a user's progress.

15 Jul 2020 11:06 #26008

Since Silverfrost use a proprietary format for 64-bit OBJ files and static libraries, users face an obstacle when they wish to use a C subroutine with their Fortran code and SCC-64 runs into a bug.

When I was in a similar situation, I used the Microsoft C compiler to produce a DLL instead of an OBJ or a static library, and linked the FTN95-compiled 64-bit code with that DLL.

17 Jul 2020 11:56 #26025

mecej4,

many thanks for your hint. I've tried to make use of it and could generate a ftn95 source from which I called into a C/CPP Dll both being created with the debug flag set. The executable worked as expected, but unfortunately I was not able to debug into the function implemented in the dll via sdbg64.

Here is the code:

Ftn95 file sample1.for:

      C_EXTERNAL MYSUM 'MYSUM' (REF,REF):INTEGER*4      
      integer*4 j,s1,s2
      s1=1
      s2=2
#IF _WIN64
      write(*,*) '64 Bit App'
#ENDIF
      j=MYSUM(s1,s2)
      write(*,*) 'j=MYSUM(s1,s2)=',j
      END

C/CPP file sample1_dll.cpp:

#include <windows.h>
#include <stdio.h>

extern 'C' __declspec(dllexport) int MYSUM (int *a, int *b)
{
    int c;
    c=*a+*b;
    printf('MYSUM contained in dll sample1_dll.dll\n');
    return c ;
}

Commands to build

ftn95 sample1.for /debug /CFPP /64
cl sample1_dll.cpp /LD /Zi
slink64 sample1.lnk

where file sample1.lnk is given by

lo sample1
lo sample1_dll.dll
file sample1.exe

and where cl is the 64 bit Microsoft C compiler. I may debug sample1.exe via command sdbg64 sample1.exe

and via F8 I may step up to function call MYSUM. Pressing F7 to step into the function does not work and steps over the function.

I thought maybe there would be a chance to step into it.

Version info:

[FTN95/x64 Ver. 8.63.0 Copyright (c) Silverfrost Ltd 1993-2020]
Microsoft (R) C/C++ Optimizing Compiler Version 14.00.50727.762 for x64

Regards, Dietmar

6 Dec 2020 4:23 #26708

I am curious about what 'C' compiler you are using for the 64-bit interfacing routines.

I understand SCC for 64-bit is unsupported, but you are using some 'C' compiler from somewhere.

My 64-bit 'C' code will not compile (compiler crashes).

Bill

6 Dec 2020 7:21 #26709

Bill

Although 64 bit SCC is officially 'unsupported', this just means that we currently do not guarantee to fix all reported bugs.

Please supply code that illustrates the compiler failure that you have encountered so that we can move towards a fully supported SCC.

6 Dec 2020 2:47 #26710

I have the folder with the source, the error.txt file from the crash (all are similar; same instruction location, different target addresses), and the CMD file. I placed a lot (but not all) of the failing compile steps at the beginning of the command file.

Here's the DropBox link. https://www.dropbox.com/t/bDu1QC4snBhnOwyu

7 Dec 2020 7:37 #26713

Bill

Thanks. I will take a look.

8 Dec 2020 2:24 #26721

Bill,

as far as I remember I used MSVC 'C/C++' Comiler (cl) to build a dll from file sample1_dll.cpp (instead of an object built with SALFORD's scc). I wanted to verify mecej4`s hint to call into a dll instead of an object in order to be able to debug into the C code. But unfortunately I was not successful in doing so 😦

We are are calling into C/C++ Code from a big 32 bit GUI app written in Fortran and we are porting this app to 64 bit using ftn95 and scc. There are some warnings and problems with 'scc /64' but we could compile much of the C/C++ code successfully.

Regards, Dietmar

Please login to reply.