hum*_*des 8 c++ mingw-w64 address-sanitizer visual-studio-code
我的 C++ 设置信息: 操作系统 - Windows 10、IDE - VS Code、编译器 - MinGw
问题:-fsanitize=address我最近发现 C++ 的清理程序可以捕获一些运行时错误,例如在我的 VS Code 环境中
进行越界数组访问-fsanitize=undefined。
当我尝试用这一行编译程序时,在 VS Code 中使用的终端是CMDg++ -fsanitize=address check.cpp -o main.exe

这是 C++ 代码->
// Program to demonstrate
// accessing array out of bounds
#include <iostream>
using namespace std ;
int main()
{
int arr[] = {1,2,3,4,5};
cout<<arr[0]<<endl;
// arr[10] is out of bound
cout<<arr[10]<<endl;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
此问题的原因/解决方案
如何修复找不到-lasan?
MinGW 不支持这些消毒剂吗?如果是,我应该使用 cygwin 吗?
我可以在 Windows 机器上安装 clang (如果可能的话)来使用这整堆消毒剂吗?
除了使用 Visual Studio 而不是 VS Code 之外,还有哪些其他选项可以使用?
任何其他建议
注意:请为我推荐适合这篇文章的标签(如果我使用了错误的标签或错过了关键的标签)
| 归档时间: |
|
| 查看次数: |
4771 次 |
| 最近记录: |