C ++ std :: sort intel编译器错误:访问冲突 [英] c++ std::sort intel compiler error : access violation

查看:73
本文介绍了C ++ std :: sort intel编译器错误:访问冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么这个简单的c ++代码段不能编译?

Why does this simple c++ code snippet do not compile?

#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);

}

编译器返回以下与std相关的错误:排序调用

The compiler returns the following error related to the std::sort call

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>                      ^

我正在使用Visual Studio Enterprise 2017 15.5.2版和Intel编译器64位版本17.0 .4.210生成20170411。

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编译器成功编译了代码。

The code is successfully compiled using the default visual studio compiler.

不能

推荐答案

我发现不幸的是Visual Studio 15.5.x更新破坏了Intel编译器在英特尔论坛我在哪里问过同样的问题。希望它对其他人也有用。

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.

这篇关于C ++ std :: sort intel编译器错误:访问冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆