Helping LLMs improve code generation using feedback from testing and static analysis
Discover Artificial Intelligence · 05.03.2026 · 6 (1)
DOI: 10.1007/s44163-026-01009-5 ↗Kurz gefasst
Fachartikel in der Zeitschrift Discover Artificial Intelligence, online erschienen am 05.03.2026. Verfasst von Greta Dolcetti und 5 weiteren Autor:innen. Die Arbeit wurde bisher 8-mal zitiert (Crossref) und nennt 40 Literaturangaben. Der Volltext ist frei zugänglich (Open Access, CC BY-NC-ND 4.0). Gefördert von: Università degli Studi di Parma.
Abstract (Originalsprache)
Large Language Models (LLMs) are one of the most promising developments in the field of artificial intelligence, and the software engineering community has readily noticed their potential role in the software development life-cycle. Developers routinely ask LLMs to generate code snippets, increasing productivity but also potentially introducing ownership, privacy, correctness, and security issues. Previous work highlighted how code generated by mainstream commercial LLMs is often not safe, containing vulnerabilities, bugs, and code smells. In this paper, we present a framework that leverages testing and static analysis to assess the quality, and guide the self-improvement, of code generated by general-purpose, open-source LLMs. First, we ask LLMs to generate C code to solve a number of programming tasks. Then we employ ground-truth tests to assess the (in)correctness of the generated code, and a static analysis tool to detect potential safety vulnerabilities. Next, we assess the models ability to evaluate the generated code, by asking them to detect errors and vulnerabilities. Finally, we test the models ability to fix the generated code, providing the reports produced during the static analysis and incorrectness evaluation phases as feedback. Our results show that models often produce incorrect code, and that the generated code can include safety issues. Moreover, they perform very poorly at detecting either issue. On the positive side, we observe a substantial ability to fix flawed code when provided with information about failed tests or potential vulnerabilities, indicating a promising avenue for improving the safety of LLM-based code generation tools.
Förderung
- Università degli Studi di Parma
Zitieren
APA
Dolcetti, G., Arceri, V., Iotti, E., Maffeis, S., Cortesi, A., & Zaffanella, E. (2026). Helping LLMs improve code generation using feedback from testing and static analysis. Discover Artificial Intelligence, 6(1). https://doi.org/10.1007/s44163-026-01009-5
Vancouver
Dolcetti G, Arceri V, Iotti E, Maffeis S, Cortesi A, Zaffanella E. Helping LLMs improve code generation using feedback from testing and static analysis. Discover Artificial Intelligence. 2026;6(1). doi:10.1007/s44163-026-01009-5
BibTeX
@article{Dolcetti2026,
author = {Dolcetti, Greta and Arceri, Vincenzo and Iotti, Eleonora and Maffeis, Sergio and Cortesi, Agostino and Zaffanella, Enea},
title = {Helping LLMs improve code generation using feedback from testing and static analysis},
journal = {Discover Artificial Intelligence},
year = {2026},
volume = {6},
number = {1},
doi = {10.1007/s44163-026-01009-5}
}
EUVIMED