Quantcast
Channel: Recent posts
Viewing all articles
Browse latest Browse all 415

Intel/VS2015 access violation in mixed language program compiled with default -MT switch

$
0
0

I have a small main program written in Fortran (attached file main.f90) and it calls a simple function written in C (attached file myprintf.c). The C function just calls printf to output the value of its double precision argument (which is passed by reference as dictated by Fortran).

I compile and link the two files like this:

  icl -MT -c myprintf.c
  ifort -MT main.f90 myprintf.obj

When I run the program, it crashes with an access violation inside a Microsoft C run-time library print function (I can see where it is using the Visual Studio debugger)

However, if I compile the files using the -MD switch, like this:

  icl -MD -c myprintf.c
  ifort -MD main.f90 myprintf.obj

then there is no problem - the program runs and prints the expected results. Note that icl and ifort use -MT switches by default so if I omit them althoghether I still get the crash. Something else - if I remove the call of ieee_is_nan() from main.f90, the problem also goes away.

I'm using ifort and icl initialized by a call of

  ifortvars.bat intel64 vs2015

- in other words, telling the Intel compilers to interoperate with the latest Microsoft C. If I use an older version of Microsoft C instead, such as vs2013, then the problem goes away. So - I imagine that the issue is to do with the well-known refactoring of the Microsoft run-time libraries in VS2015.

But - I'm using the latest versions of Intel and Microsoft compilers, which I thought were intended to work properly together. Here are my compiler versions:

  Intel(R) C++ Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 16.0.3.207 Build 20160415
  Intel(R) Visual Fortran Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 16.0.3.207 Build 20160415
  Microsoft (R) C/C++ Optimizing Compiler Version 19.00.24210 for x64

So - am I doing something wrong? Or are the compilers? Or what?

I'd like to get this to work - this test program is cut down from a large amount of code. I work for a company making software libraries and many of our customers require the ability to link statically to libraries built with the -MT switch.

Mick


Viewing all articles
Browse latest Browse all 415

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>