CoChat

Helping LLMs improve code generation using feedback from testing and static analysis

Open access
Dolcetti, Greta, Arceri, Vincenzo, Iotti, Eleonora, Maffeis, Sergio, Cortesi, Agostino, Zaffanella, Enea · 2026 · Discover Artificial Intelligence

Published version of a preprint

The DOI matches its Crossref record; 36 of the 36 references it cites were found in a registry or an index; none of the 19 sources its claims cite is checked for support yet.

Abstract

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.

Overview

CoChat Summary

TL;DR

The paper evaluates four open-source LLMs on C code generation, self-evaluation, and repair using unit tests plus Infer static analysis on an MBPP-derived benchmark of 89 tasks. It finds that generated code is more often functionally incorrect than insecure, self-evaluation is poor, and repair improves both correctness and safety when the models are given test or analyzer feedback.

Key findings

  • After benchmark creation and cleaning, 89 tasks compiled for all models, yielding a GEN dataset of 356 files; across these, correctness ranged from 46% for gemma-7b-it to 65% for llama3-70b-8192.
  • Infer found 44 vulnerabilities in total on the GEN dataset; safe files were 328/356 overall, and by model the safe-file counts were 85, 84, 82, and 77 for gemma-7b-it, llama3-8b-8192, llama3-70b-8192, and mixtral-8x7b-32768, respectively.
  • Self-evaluation performed poorly: for correctness, F1-scores were all reported as poor, with one model often replying almost always YES and another almost always NO; for safety, all F1-scores were under 0.3.
  • Repair improved outcomes: the best correctness repair result was 96 out of 155 incorrect files (62%), and the best safety repair result fixed 39 out of 44 vulnerabilities (89%); overall, the paper says about 77% of previously detected vulnerabilities were fixed.

Methods

  • Built a benchmark by randomly selecting 100 MBPP tasks, translating them to C, and manually adapting unit tests; after compilation, 89 tasks remained in the GEN dataset.
  • Evaluated four open-source instruction-tuned models: gemma-7b-it, llama3-8b-8192, llama3-70b-8192, and mixtral-8x7b-32768, queried through the Groq API at temperature 0.2.
  • Ran a three-phase pipeline: code generation, self-evaluation, and repair; correctness was checked with MBPP-derived unit tests, and safety with Infer on compiling programs, with up to 6 repair iterations.

Limitations

  • The paper states that using a crafted C version of MBPP does not entirely eliminate memorization risk, because parts of the task formulation may still overlap with training data.
  • It also states that Infer is neither complete nor sound, so it can produce false positives and false negatives; the authors manually inspected detected vulnerabilities.
  • Evident from the text: the benchmark was reduced from 100 selected tasks to 89 compiling tasks, and the study is limited to C and to the four chosen open-source models, so the results may not generalize beyond that setting.

Model-written summary of a shortened version of the paper’s full text (it is longer than we read). Check it against the paper before relying on it.

Integrity signals

Registry

Crossref · 10.1007/s44163-026-01009-5

Cites

36 of 36 references verified0 citation errors · 0 not checkable

Statistics

Nothing to recompute.

Verification

Claims the paper makes

0 Valid · 2 Not valid · 12 Not checked · 100 Own results and interpretations

44 more claims

Create a free account to see all 114 claims and to verify the 19 references still open.

See all claims — free account
  • It may state two separate claims as one. 37
  • Probably not a substantial claim. 41
  • The quote only partly states this claim. 3

Create a free account to see these claims.

Self-check

Percentages, sums and reported differences re-computed from the paper’s own numbers.

Each contradiction between two passages listed here was confirmed by an independent check.

3 of 3

Citations

Cites

Show all 36 references

Research works printed but not linked: 7

  1. Gartner: gartner hype cycle shows ai practices and platform engineering will reach mainstream adoption in software engineering in two to five years 2024. https://www.gartner.com/en/newsroom/press-releases/2023-11-28-gartner-hype-cycle-shows-ai-practices-and-platform-engineering-will-reach-mainstream-adoption-in-software-engineering-in-two-to-five-years.
  2. Austin J, Odena A, Nye MI, Bosma M, Michalewski H, Dohan D, Jiang E, Cai CJ, Terry M, Le QV, Sutton C. Program synthesis with large language models. 2021 CoRR arXiv:abs/2108.07732.
  3. Wei J, Wang X, Schuurmans D, Bosma M, Ichter B, Xia F, Chi EH, Le QV, Zhou D. Chain-of-thought prompting elicits reasoning in large language models. In: Koyejo S, Mohamed S, Agarwal A, Belgrave D, Cho K, Oh A. (eds.) Advances in Neural Information Processing Systems 35: Annual Conference on Neural Information Processing Systems 2022, NeurIPS 2022, New Orleans, LA, USA, November 28 - December 9, 2022 2022. http://papers.nips.cc/paper_files/paper/2022/hash/9d5609613524ecf4f15af0f7b31abca4-Abstract-Conference.html.
  4. Zhou Y, Muresanu AI, Han Z, Paster K, Pitis S, Chan H, Ba J. Large language models are human-level prompt engineers. In: The Eleventh International Conference on Learning Representations, ICLR 2023, Kigali, Rwanda, May 1–5, 2023. OpenReview.net, 2023. https://openreview.net/forum?id=92gvk82DE-.
  5. Olausson TX, Inala JP, Wang C, Gao J, Solar-Lezama A. Is self-repair a silver bullet for code generation? In: The Twelfth International Conference on Learning Representations, 2023.
  6. Islam NT, Khoury J, Seong A, Bou-Harb E, Najafirad P. Enhancing source code security with llms: demystifying the challenges and generating reliable repairs. In: Network and Distributed System Security (NDSS) Symposium 2024, 2024.
  7. He J, Vero M, Krasnopolska G, Vechev MT. Instruction tuning for secure code generation. In: Forty-first International Conference on Machine Learning, ICML 2024, Vienna, Austria, July 21–27, 2024. OpenReview.net, 2024. https://openreview.net/forum?id=MgTzMaYHvG.

Cited by

See all 8

Metadata

Authors
Dolcetti, G., Arceri, V., Iotti, E., Maffeis, S., Cortesi, A., & Zaffanella, E.
Affiliations
  • Ca' Foscari University of Venice (IT)
  • University of Parma (IT)
  • Imperial College London (GB)
Corresponding author
Dolcetti, Greta
Venue
Discover Artificial Intelligence
Published
2026-03-05
Volume
6
Issue
1
ISSN
2731-0809 (ISSN-L)
OpenAlex
W4405634796
Cited by
8
References
26
Citations by year
2026: 6
FWCI
51.04
Type
journal article
Language
en
Open access
Licence
Locations
  • Discover Artificial Intelligence (publishedVersion, cc-by-nc-nd)
  • arXiv (Cornell University) (submittedVersion, cc-by)
  • ARCA (Università Ca' Foscari Venezia) (submittedVersion, cc-by-nc-nd)
  • DOAJ (DOAJ: Directory of Open Access Journals) (submittedVersion, cc-by-sa)
  • arXiv (Cornell University) (cc-by)
Funders
Università degli Studi di Parma
Topics
  • Physical Sciences › Computer Science › Information Systems › Software Engineering Research
  • Physical Sciences › Computer Science › Software › Software Testing and Debugging Techniques
  • Physical Sciences › Computer Science › Information Systems › Software Engineering Techniques and Practices
Keywords
large language models, code generation, static analysis, software testing, code safety, vulnerability detection, bug detection, code repair, C programming

About these checks

Registry, retraction, Cites and statistics results are computed, not judged, with one exception: a printed reference that no index lists is read once by a model before it counts as a citation error. Claims are extracted by a model and kept only when their quote appears verbatim in the text; each cited source is then checked, with a model’s help, for whether it says what the claim relies on. Those verdicts can be wrong — read the claim’s quote and the cited source before relying on one.

A language model drew the claims from the paper on 2026-10-11, under version 3 of the claim definition (model deepseek-v4.1-flash, prompt extract-v3).

A second model labelled each claim on 2026-10-11 (model jev-1.13-20260917, definition revision gold-guideline-v0.2).

Statistics and arithmetic are recomputed, not judged.

Confidence bands are shown only for fields calibrated on our annotated test set. None is calibrated yet, so no band is shown.

What counts as a claim ›How we measure confidence ›How we check this ›

Are you an author, or do you see a problem with this page? Request a review

How to cite

Cite CoChat for the checks on this page, and the paper for its own findings.

This page
CoChat. (2026). Citation check: Helping LLMs improve code generation using feedback from testing and static analysis. https://app.cochat.ai/papers/10.1007/s44163-026-01009-5
The paper
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. https://doi.org/10.1007/s44163-026-01009-5

Data sources

Bibliographic data: Semantic Scholar, OpenAlex, Crossref.

Contains information from the Semantic Scholar Academic Graph Datasets, made available under the ODC Attribution License (ODC-BY 1.0).

Semantic Scholar’s data is described in: Kinney, R., et al. (2023). The Semantic Scholar Open Data Platform. arXiv:2301.10140.