With the rapid development of large language models in code generation, AI-powered editors such as GitHub Copilot and Cursor are revolutionizing software development practices. At the same time, studies have identified potential defects in the generated code. Previous research has predominantly examined how code context influences the generation of defective code, often overlooking the impact of defects within commented-out code (CO code). AI coding assistants' interpretation of CO code in prompts affects the code they generate. This study evaluates how AI coding assistants, GitHub Copilot and Cursor, are influenced by defective CO code. The experimental results show that defective CO code in the context causes AI coding assistants to generate more defective code, reaching up to 58.17 percent. Our findings further demonstrate that the tools do not simply copy the defective code from the context. Instead, they actively reason to complete incomplete defect patterns and continue to produce defective code despite distractions such as incorrect indentation or tags. Even with explicit instructions to ignore the defective CO code, the reduction in defects does not exceed 21.84 percent. These findings underscore the need for improved robustness and security measures in AI coding assistants.


翻译:随着大型语言模型在代码生成领域的快速发展,GitHub Copilot和Cursor等AI驱动的编辑器正在革新软件开发实践。与此同时,研究已发现生成代码中存在的潜在缺陷。先前的研究主要考察了代码上下文如何影响缺陷代码的生成,却常常忽略了注释代码(CO代码)中缺陷的影响。AI编程助手对提示中注释代码的解读会影响其生成的代码。本研究评估了GitHub Copilot和Cursor这两种AI编程助手如何受到有缺陷注释代码的影响。实验结果表明,上下文中的有缺陷注释代码会导致AI编程助手生成更多有缺陷的代码,比例高达58.17%。我们的发现进一步表明,这些工具并非简单地复制上下文中的缺陷代码。相反,它们会主动推理以补全不完整的缺陷模式,并且即使存在错误缩进或标签等干扰因素,仍会持续生成有缺陷的代码。即使给出明确指令要求忽略有缺陷的注释代码,缺陷的减少率也不超过21.84%。这些发现凸显了AI编程助手在鲁棒性和安全性措施方面亟待改进的必要性。

0
下载
关闭预览

相关内容

代码(Code)是专知网的一个重要知识资料文档板块,旨在整理收录论文源代码、复现代码,经典工程代码等,便于用户查阅下载使用。
AI生成代码缺陷综述
专知会员服务
16+阅读 · 2025年12月8日
通过强化学习增强代码生成中的代码大语言模型:综述
专知会员服务
29+阅读 · 2025年1月1日
【新书】《学习AI辅助的Python编程(第2版)》
专知会员服务
66+阅读 · 2024年10月22日
《大型语言模型代码生成》综述
专知会员服务
68+阅读 · 2024年6月4日
《深度学习代码智能》综述、基准和工具集
专知会员服务
56+阅读 · 2024年1月2日
深度学习赋能的恶意代码攻防研究进展
专知会员服务
30+阅读 · 2021年4月11日
专知会员服务
16+阅读 · 2021年1月23日
八个不容错过的 GitHub Copilot 功能!
CSDN
11+阅读 · 2022年9月22日
AI可解释性文献列表
专知
43+阅读 · 2019年10月7日
【资源推荐】AI可解释性资源汇总
专知
47+阅读 · 2019年4月24日
深度学习中的注意力机制
人工智能头条
16+阅读 · 2017年11月2日
国家自然科学基金
4+阅读 · 2017年12月31日
国家自然科学基金
18+阅读 · 2017年12月31日
国家自然科学基金
6+阅读 · 2017年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
4+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
VIP会员
相关VIP内容
AI生成代码缺陷综述
专知会员服务
16+阅读 · 2025年12月8日
通过强化学习增强代码生成中的代码大语言模型:综述
专知会员服务
29+阅读 · 2025年1月1日
【新书】《学习AI辅助的Python编程(第2版)》
专知会员服务
66+阅读 · 2024年10月22日
《大型语言模型代码生成》综述
专知会员服务
68+阅读 · 2024年6月4日
《深度学习代码智能》综述、基准和工具集
专知会员服务
56+阅读 · 2024年1月2日
深度学习赋能的恶意代码攻防研究进展
专知会员服务
30+阅读 · 2021年4月11日
专知会员服务
16+阅读 · 2021年1月23日
相关基金
国家自然科学基金
4+阅读 · 2017年12月31日
国家自然科学基金
18+阅读 · 2017年12月31日
国家自然科学基金
6+阅读 · 2017年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
4+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员