Why does this simple c++ code snippet do not compile?
为什么这个简单的c ++代码片段无法编译?
#include <algorithm>
#define SIZE (1000)
struct S {
int *vect;
};
int main() {
struct S* s = static_cast<struct S*>(malloc(sizeof(struct S)));
s->vect = static_cast<int*>(malloc(sizeof(int) * SIZE));
for(int i = 0; i < SIZE; i++) {
s->vect[i] = i;
}
std::sort(s->vect, s->vect + SIZE);
}
The compiler returns the following error related to the std::sort call
编译器返回与std :: sort调用相关的以下错误
1>C:\Program Files (x86)\Microsoft Visual
Studio\2017\Enterprise\VC\Tools\MSVC\14.12.25827\include\algorithm(3138):
error : access violation
1> return (pair<_RanIt, _RanIt>(_Pfirst, _Plast));
1> ^
I'm using visual studio enterprise 2017 version 15.5.2 and the intel compiler 64 bit version 17.0.4.210 Build 20170411.
我正在使用visual studio enterprise 2017版本15.5.2和intel编译器64位版本17.0.4.210 Build 20170411。
The code is successfully compiled using the default visual studio compiler.
使用默认的visual studio编译器成功编译代码。
Can't find out what I'm doing wrong.
无法找出我做错了什么。
1 个解决方案
#1
0
I've found out that unfortunately visual studio update 15.5.x breaks Intel Compiler 2017 as can be seen in the intel forum where I asked this same question. Hope it will be useful to others too.
我发现不幸的是,视觉工作室更新15.5.x打破了英特尔编译器2017,我可以在英特尔论坛上看到我问同样的问题。希望它对其他人也有用。
#1
0
I've found out that unfortunately visual studio update 15.5.x breaks Intel Compiler 2017 as can be seen in the intel forum where I asked this same question. Hope it will be useful to others too.
我发现不幸的是,视觉工作室更新15.5.x打破了英特尔编译器2017,我可以在英特尔论坛上看到我问同样的问题。希望它对其他人也有用。