把 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. 修改MySql 数据默认存储路径

    1. cmd进入控制台 net stop mysql 2.复制原来数据库目录到新目录 复制C:\ProgramData\MySQL\MySQL Server 5.5\中的data目录到 D:\Prog ...

  2. 项目中 -- 设置tabBar样式 (旅游局)

    - (void)addChildViewController:(UIViewController *)ViewController image:(UIImage *)image selectImg:( ...

  3. kettle系列-5.kettle实现二进制文件迁移

    本文就是分享下二进制文件(图片.txt文件等)在oracle和文件系统间的传输的转换示例. 转换示例如下图: 示例本身较简单,但很多人应该还是不太清楚怎么做,很多时候都是上网搜索,网上有关的就是通过j ...

  4. LeetCode 206 Reverse a singly linked list.

    Reverse a singly linked list. Hint: A linked list can be reversed either iteratively or recursively. ...

  5. 【Java EE 学习 70 下】【数据采集系统第二天】【Action中User注入】【设计调查页面】【Action中模型赋值问题】【编辑调查】

    一.Action中User注入问题 Action中可能会经常用到已经登陆的User对象,如果每次都从Session中拿会显得非常繁琐.可以想一种方法,当Action想要获取User对象的时候直接使用, ...

  6. HTML5教程之html 5 本地数据库(Web Sql Database)

    HTML5的Web SQL Databases(html5 本地数据库)的确很诱惑人,当你发现可以用与mysql查询一样的查询语句来操作本地数据库时,你会发现这东西挺有趣的.今天,我们一起来了解HTM ...

  7. C#设置IE代理及遇到问题的解决方案

    起初使用的方法是修改完一次代理之后就不能继续修改,需要重新启动一次进程才可以,最初代码是: private void ShowProxyInfo() { if (!GetProxyStatus()) ...

  8. 优化Linux内核参数

    转自:http://www.centoscn.com/CentOS/config/2013/0804/992.html vim /etc/sysctl.conf 1.net.ipv4.tcp_max_ ...

  9. ceshi

    % void CLASS cam_xyz_coeff (float rgb_cam[3][4], double cam_xyz[4][3]) % { % double cam_rgb[4][3], i ...

  10. python 学习第三天

    一,Python的数据结构-集合 1,集合的定义 Python中集合是以{}括起来的,例如x=set({1,2,3,4,5}),这就是一个集合,集合的特点有:(1),去重的(2),无序的,集合的作用用 ...