变量'...'周围的堆栈已损坏 [英] Stack around the variable '...' was corrupted

查看:343
本文介绍了变量'...'周围的堆栈已损坏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在MSVC 15.8.5的调试模式下,我得到了

On MSVC 15.8.5 in debug mode I get that


运行时检查失败#2-围绕变量'insert_into '
已损坏。

Run-Time Check Failure #2 - Stack around the variable 'insert_into' was corrupted.

MSVC中是否存在错误,或者我做错了什么?

Is there a bug in MSVC or have I done something bad?

在clang版本6.0.0-1ubuntu2和clang版本7.0.0-svn341916-1〜exp1〜20180911115939.26上运行良好

Runs fine on clang version 6.0.0-1ubuntu2 and clang version 7.0.0-svn341916-1~exp1~20180911115939.26

#include <set>

template <typename... T>
struct Overload : T...
{
//support struct for combining and overloading multiple lambdas
    using T::operator()...;
};
template <typename... T>
Overload(T...)->Overload<T...>;

using BuiltSet = std::set<std::string>;

template <typename... Args>
BuiltSet MakeBuildSet(const Args&... args)
{
//takes a list of arguments if an argument is a 
// BuiltSet each element is added to headers, 
// otherwise the arg itself is added to headers
    BuiltSet headers{};

//Construct a lambda with overloading on if argument is a BuiltSet or not
    const Overload insert_into{
        [](const BuiltSet& h, BuiltSet& headers) {
            headers.insert(h.begin(), h.end());
        },
        [](const auto& arg, BuiltSet& headers) { 
            headers.insert(arg); 
        }
    };
//Fold over arguments applying the lambda on each element
    (insert_into(args, headers), ...);
    return headers;
}

int main(int argc, char** argv)
{
    MakeBuildSet(MakeBuildSet("a", "b", "c"), "a", "b", "c");
    return 0;
}


推荐答案

MSVC错误,因此这是编译器中的缺陷。

MSVC bug so it is a flaw in the compiler.

这篇关于变量'...'周围的堆栈已损坏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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