把 project->配置属性->c/c++->代码生成->基本运行时检查 为 默认值 就不会报本异常。具体原因正在研究中。。。

如果改为其他就有exception。

exception有时是有道理的

// step 1
STRINGC2& STRINGC2::operator += (const char x)
{
// if (x == 0) return *this;

char ptr[1]; // max is 1 digit

ptr[0] = x;
ptr[1] = '/0';
*this += ptr; // off to step 2 and back

return *this; // step 4 crash
}
这个也会导致上述exception。

问题描述:

Problem
 
The following error message occurs when building on Test RealTIme environment with the cvisual7 TDP?

Run-Time Check Failure #2 - Stack around the variable 'xxx' was corrupted. 
 
Cause 
Stack pointer corruption is caused writing outside the allocated buffer in stack memeory.
 
Solution
This
kind of error is detected by setting /RTC1 compiler option from menu
Project -> Settings -> Configuration properties -> Build ->
Compiler -> Compiler flags when using TDP cvisual7 in IBM® Rational®
Test RealTime environment.. This enables stack frame run-time error
checking. For example, the following code may cause the above error messge.

#include <stdio.h>
#include <string.h>

#define BUFF_LEN 11 // 12 may fix the Run-Time Check Failure #2
int rtc_option_test(char * pStr);

int main()
{
char * myStr = "hello world";
rtc_option_test(myStr);
return 0;
}

int rtc_option_test(char * pStr)
{
char buff[BUFF_LEN];
strcpy(buff, pStr); //cause Run-Time Check Failure #2 - Stack around
//the variable 'buff' was corrupted.
return 0;
}

vs中“Stack around the variable was corrupted”的解决方案的更多相关文章

  1. C语言 在VS环境下一个很有意思的报错:stack around the variable was corrupted

    今天做一个很简单的oj来温习下c 语言 题目如下 输入 3位正整数 输出 逆置后的正整数 代码如下: #include"stdio.h"int main(){ float h,su ...

  2. vs中 Stack around the variable 'XXX' was corrupted.

    https://blog.csdn.net/hou09tian/article/details/75042206 把 project->配置属性->c/c++->代码生成->基 ...

  3. 运行时错误:“stack around the variable…was corrupted”

    造冰箱的大熊猫@cnblogs 2018/11/1 引发问题的代码片段如下 WORD var; scanf ( "%d", &var ); 包含上述代码的程序,编译正常,运 ...

  4. 关于stack around the variable “” was corrupted问题

    很坑爹的问题,异常信息表示我的缓冲区如数组越界了,可是老子明明没有越界. 解决方法:关闭vs检查代码是否越界的功能: 属性->c/c++->代码生成->基本运行时检查,改为默认值

  5. stack around the variable “ ” was corrupted

    用scanf格式控制不当经常发生此错误. 如 short int a=10;  scanf("%d",&a); 应该是%hd; 一般是越界引起的. 参看:http://bl ...

  6. VS2008中Run-Time Check Failure #2 - Stack around the variable 'xxx' was corrupted 错误解决方法

    问题 : 在用VS2008写一段代码,算法都没有问题,但是调试的时候发现出了main之后就报 Stack around the variable 'xxx' was corrupted 的错误,后来发 ...

  7. Run-Time Check Failure #2 Stack around the variable ‘xxx’ was corrupted

    在改别人代码时,运行报错: Run-Time Check Failure #2 Stack around the variable 'buffer' was corrupted 这表明你对某变量的赋值 ...

  8. Stack around the variable 'szStr' was corrupted.

    错误:stack around the variable “XX” was corrupted.,中文翻译就是“在变量XX周围的堆栈已损坏”. 把 project->配置属性->c/c++ ...

  9. c++. Run-Time Check Failure #2 - Stack around the variable 'cc' was corrupted.

    Run-Time Check Failure #2 - Stack around the variable 'cc' was corrupted. char cc[1024];   //此处如果索引值 ...

随机推荐

  1. java常见的问题

    1.   接口与抽象类的区别? 抽象类:含有abstract修饰的class即为抽象类abstract类不能创建实例对象,不能有抽象的构造方法或抽象的静态方法,如果子类没有实现抽象父类中的所有 方法, ...

  2. 用python实现一个不排序的列表功能

    #!/usr/bin/env python # -*- coding: utf-8 -*- # learn <<Problem Solving with Algorithms and Da ...

  3. 解决文件上传插件Uploadify在火狐浏览器下,Session丢失的问题

    因为在火狐浏览器下Flash发送的请求不会带有cookie,所以导致后台的session失效. 解决的方法就是手动传递SessionID到后台. $("#fileresultfiles&qu ...

  4. 远程登录VirtualBox虚拟机Linux

    通过端口转发的方式,使用终端(如MobaXterm,Xshell,putty等终端)远程登录本机虚拟机Linux, 打开虚拟机,找到 [设置]-->[网络]--> [网卡1] 确认以下设置 ...

  5. Python-模块的使用

    基础概念 - 模块是Python组织代码的基本方式 - 一个Python脚本可以单独运行,也可以导入到另一个脚本中运行,当脚本被导入运行时,我们将其称为模块(module) - 所有的.py文件都可以 ...

  6. 在IIS8.5的环境下配置WCF的Restful Service

    今天在客户的环境中(Windows Server 2012 R2 + IIS 8.5)搭建Call WCF Restful Service的功能,发现了几个环境配置的问题,记录如下: 1):此环境先安 ...

  7. java时间计算,获取某月第一天和最后一天

    //获取前月的第一天 SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd"); //获取当前月第一天: Calendar ...

  8. Drools 函数学习

    Drools 函数学习 函数是定义在规则文件当中一代码块,作用是将在规则文件当中若干个规则都会用到的业务操作封装起来,实现业务代码的复用,减少规则编写的工作量.函数的编写位置可以是规则文件当中 pac ...

  9. echarts中显示效果option中必有的属性

    写一个最简单的效果让option中不可缺少的属性. var option = { xAxis:[ //x轴,数组对象,其下至少有一个对象 {.....} ], yAxis:[//y轴,数组对象,其下可 ...

  10. node - glob模块

    node的glob模块允许你使用 *等符号, 来写一个glob规则,像在shell里一样,获取匹配对应规则的文件. 这个glob工具基于javascript.它使用了 minimatch 库来进行匹配 ...