加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

stack around the variable * was corrupted

(2012-06-15 19:42:10)
标签:

stack

around

the

variable

was

corrupted

分类: VC


今天 运行项目的时候,出现了这个问题,

 

stack around the variable * was corrupted. 翻译意思是 堆栈变量周围已损坏.

 

http://s3/middle/50a0aa5etc2815f90f372&690around the variable was corrupted" TITLE="stack around the variable was corrupted" />
以下是我写的测试代码:


#include "stdafx.h"


int _tmain(int argc, _TCHAR* argv[])
{
 int a[5] = {0,0,0,0,0};

 a[5]=1;
 return 0;
}

 

这个赋值语句真是有意思,用越界的数组进行赋值, 这是我今天运行以前别人写的代码里就出现了这个问题,以前没有遇到过 ,可能以前就没有测试到这个地方,在release 里运行就不会有问题 ,在debug里会报错,是release里设置的问题。

 

在 项目--属性--C/C++ -- 代码生成 -- 基本运行时检查 设置。release 是默认值 而debug 里是 两者(/RTC1,等同于 /RTCsu)

 

用 #pragma runtime_checks( "", off ) 也可以打开检查很多内容,具体的我不知道怎么翻译,翻译的不太好就不翻译了,不过我看都差不多,可以使用#pragma runtime_checks( "scu", off )就全部设置了。

 

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有