Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

Compilation error on Windows (access violation)

Jiri_F_
Beginner
1,440 Views

Hi,

the following code does not compile with Intel Parallel Studio 2013 SP1 on Windows (combined with Visual Studio 2013):

[cpp]

#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(int argc, char* argv[])
{
        vector<double> d{ 1.0 };   // Compiles OK
        vector<string> s{ "hi" };  // Does not compile on windows!

        return 0;

}

[/cpp]

The compilation on Windows fails with access violation.

The linux version of the compiler works fine...

Best regards,

Jiri

 

 

0 Kudos
1 Solution
Judith_W_Intel
Employee
1,423 Views

 

You need to reproduce it in a MSVC++ 2013 environment, since that is the first visual stdio with support for the std::initializer_list class.

I think this is the same as DPD200249985 which was an access violation on Windows when you tried to create an initializer_list with an object type that contains a destructor (like string). This was fixed on 12/26 so you should not see this problem in the next 14.0 update.

Sorry for the inconvenience.

Judy

View solution in original post

0 Kudos
20 Replies
Bernard
Valued Contributor I
1,409 Views

Can you post more details about the access violation error?

In general if it is crash during compilation phase in such a case it could be  compiler internal error.

0 Kudos
Jiri_F_
Beginner
1,409 Views

Here is the output from VS Output window:

[plain]

1>------ Build started: Project: ConsoleApplication2, Configuration: Debug Win32 ------
1>  ConsoleApplication2.cpp
1>ConsoleApplication2.cpp(10): error : access violation
1>        vector<string> s{ "hi" };  // Does not compile on windows!
1>                       ^
1>  
1>  compilation aborted for ConsoleApplication2.cpp (code 4)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

[/plain]

Runnig from the command line on Windows gives

[plain]

C:\Users\furst\Documents\Visual Studio 2013\Projects\ConsoleApplication2\ConsoleApplication2>icl /Qstd=c++11 ConsoleApplication2.cpp
Intel(R) C++ Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 14.0.1.139 Build 20131008
Copyright (C) 1985-2013 Intel Corporation.  All rights reserved.

ConsoleApplication2.cpp
ConsoleApplication2.cpp(10): internal error: access violation
        vector<string> s{ "hi" };  // Does not compile on windows!
                       ^

[/plain]

So it is probably an internal compiler error. It is strange that the same compiler on linux works.

In fact we found this issue when porting an application from linux (where we are using intel compiler, gcc48 and clang 3.2). The compilation on windows fails in the same way when trying to do following

[cpp]

std::map<std::string,double> conversion{ {"m", 1.0}, {"km", 1000.0}, {"mm", 1.e-3} };

[/cpp]

Best regards,

Jiri

 

0 Kudos
Bernard
Valued Contributor I
1,409 Views

Can you try to compile it as a release build?

0 Kudos
Jiri_F_
Beginner
1,409 Views

The same happens in Release mode, both for Win32 and x64. Even command line compilation with /O1, or /fast fails ...

0 Kudos
Bernard
Valued Contributor I
1,409 Views

It seems that error could be related to the allocation of the vector of  String s object.I think that string "Hi" initializer or offset/pointer to it can be a culprit.

0 Kudos
Bernard
Valued Contributor I
1,409 Views

Can you upload minidump file?

0 Kudos
Jiri_F_
Beginner
1,409 Views

I didn't find minidump on my computer :(.

0 Kudos
Bernard
Valued Contributor I
1,409 Views

Where did you search for it?Such a file usually is called minidump.dmp

0 Kudos
Bernard
Valued Contributor I
1,409 Views

You can also instruct windbg to be called upon a occurrence of access violation exception.

0 Kudos
Jiri_F_
Beginner
1,409 Views

I was looking into \Windows (according to the stup in tch "Computer/Properties/..."). After that, I was using windows search function ("Start/Find ...") for minidump, minidump.dmp, and memory.dmp.

I don't have widbg. Sorry for my ignorance, but I'm working mainly with linux and the linux version works well in his case. Are you able to compile my code with the latest intel compiler for windows? 

0 Kudos
TimP
Honored Contributor III
1,409 Views

With my attempt to recreate your source code,  icl 14.0.1 (with VS2012 pro) says

jiri.cpp(8): error: no instance of constructor "std::vector<_Ty, _Alloc>::vector
 [with _Ty=double, _Alloc=std::allocator<double>]" matches the argument list
            argument types are: (double)
    vector<double> d  { 1.0 };  // Compiles OK
                      ^

jiri.cpp(9): error: no instance of constructor "std::vector<_Ty, _Alloc>::vector
 [with _Ty=std::string, _Alloc=std::allocator<std::string>]" matches the argumen
t list
            argument types are: (const char [3])
    vector<string> s  { "hi"};                  // Does not compile on windows!

There's no internal error with my current copy of ICL.  I wouldn't waste time with 14.0.0 or assume that the two have identical behavior.

Is this something which is expected to require VS2013 as well as -Qstdc++11 ?   I was never able to get a copy of VS2013 myself, my latest VS was downgraded to VS2012 pro less than 2 months ago.

And yes, g++ 4.8.2 on Win8.1-64 accepts the source code.

0 Kudos
Judith_W_Intel
Employee
1,424 Views

 

You need to reproduce it in a MSVC++ 2013 environment, since that is the first visual stdio with support for the std::initializer_list class.

I think this is the same as DPD200249985 which was an access violation on Windows when you tried to create an initializer_list with an object type that contains a destructor (like string). This was fixed on 12/26 so you should not see this problem in the next 14.0 update.

Sorry for the inconvenience.

Judy

0 Kudos
Jiri_F_
Beginner
1,409 Views

Hi,

VS13 compiles the code without problem. The problem is apparently in the Intel compiler.

This is VS13 command line output:

[plain]

E:\>cl /EHsc ConsoleApplication2.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 18.00.21005.1 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

ConsoleApplication2.cpp
Microsoft (R) Incremental Linker Version 12.00.21005.1
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:ConsoleApplication2.exe
ConsoleApplication2.obj

[/plain]

Looking forward to next release.

Thanks all for cooperation.

Jiri

0 Kudos
Bernard
Valued Contributor I
1,409 Views

@Jiri

I think that vector String object constructor cannot be initialised with the char array.By looking at the output description provided by Tim.

0 Kudos
Bernard
Valued Contributor I
1,409 Views

@Jiri

You can create a full process dump from within task manager.

0 Kudos
Jiri_F_
Beginner
1,409 Views

@ilyaplak

Tom's post shows that icl 14 + VS12 does not support new style initialization (part of C++ 11 standard). As you can see, his compilation fails even with vector<double> d{1.0};. (I don't know if Tim compiled with /Qstd=c++11). I guess that the problem is rather an intel compiler bug. See the post by Judith, she mention that similar bug was already discovered and fixed in the upcoming release.

The isn't in initialization with char array. The same problem is occurs in

[cpp]

vector<string> v { string("Hi") };

[/cpp]

I really believe to Judith's post. I tried to compile

[cpp]

#include <vector>

using namespace std;

class C {
public:
  double x;
  double y;
  ~C() {};
};

int main() {

  vector<C> v { {1.0,2.0} };

  return 0;
}

[/cpp]

and it fails with access violation on widows (on linux it works). If I comment out the destructor, it compiles fine.

 

0 Kudos
Jiri_F_
Beginner
1,409 Views

It seems that the issue was really solved in the current release of windows compiler (2013 SP1 update 2). Now it compiles fine.

 

Thanks,

 

Jiri

0 Kudos
bernaske
New Contributor I
1,409 Views

Hi Jiri,

i have compiled under openSUSE 13.2 Linux with the option -std=c+11 no problems,

on compile.

best regards

Franz

 

0 Kudos
Jiri_F_
Beginner
1,409 Views

Yes, that is what I said in my first comment. Linux version compiles the code without problems. The problem was only with windows version 2013 SP1 update 1 (and probably with earlier too), the update 2 solves this problem. BTW You are running at openSUSE 13.2? As far as I know the latest release is 13.1 and 13.2 should be ready during November.

0 Kudos
bernaske
New Contributor I
1,239 Views

Hi Jiri,

yes i'm running a the openSUSE Factory  Build 050 name 13.2 Harlekin, also on a other workstation i have installed  openSUSE 13.1,

my server runs with SUSE Enterprise Server SLES 11 SP3 ,

all works fine with the Parallel Studio XE SP1 update 1, i personal prefer the openSUSE 13.2 (Factory x86_64)

yes the first Beta from the 13.2 is planed for November 2014,

have a nice day

Franz

 

0 Kudos
Reply