Bugs in Large Language Models Generated Code: An Empirical Study

Florian Tambon, Arghavan Moradi Dakhel, Amin Nikanjam, Foutse Khomh, Michel C. Desmarais, Giuliano Antoniol ยท pdf ยท 2024-03-13 source โ†— Reader ๐Ÿ–ฅ๏ธ

Coding AgentsTest-Driven Development
Bugs in LLM-generated code are not simply a noisier version of human bugs but form a distinct, empirically-grounded taxonomy of 10 patterns โ€” and roughly two-thirds of observed bugs (Wrong Attribute, Hallucinated Object, Prompt-biased Code, Non-Prompted Consideration) stem from the model's generative/stochastic nature rather than from prompt underspecification, meaning no amount of better prompting will eliminate them and tooling built on human-bug assumptions (like mutation-based program repair) will systematically underperform on AI-generated code.

theoretical ยท mixed โ€” Primarily a theoretical/empirical contribution (a validated taxonomy of bug patterns), but closes with explicit practical recommendations for both LLM users and researchers, so the piece argues both 'this is the structure of the phenomenon' and 'here is what to do about it.'

Structure

PartRole
Motivating example (the 'parser_flags' function that silently adds an unrequested sort) establishing that LLM code can look correct while being subtly, non-obviously wrong.context / motivation
Methodology: 333 buggy Python samples manually open-coded from 1,997 CoderEval-flagged buggy outputs of three LLMs (CodeGen, PanGu-Coder, Codex), yielding a 10-category taxonomy with 78.2% initial inter-rater agreement.evidence / method
RQ1 results: the taxonomy itself, each pattern's frequency, and distribution across tasks and dependency ('runnable') levels.evidence
RQ2 results: a 34-respondent practitioner/researcher survey validating that all 10 patterns are real, frequent, and vary in diagnosing/fixing difficulty; correlation analysis against CoderEval's distribution (strongest for Codex, ฯ=0.47).evidence / validation
Lessons learned for LLM users (prompt engineering, more testing, calibrating generation vs. completion vs. manual coding) and for researchers (repair tooling, benchmarks, interpretability).practical recommendation
Related work comparison, specifically rebutting Fan et al.'s claim that LLM bugs share human-like repair patterns, attributing the discrepancy to CoderEval's more realistic, GitHub-mined tasks versus LeetCode-style benchmarks.counter-evidence / positioning

Key terms

Propositions

Arguments

LLM-generated code bugs are categorically different from human-authored bugs โ€” not just more frequent or sloppier โ€” which undercuts the common framing of LLMs as merely a faster, slightly-less-careful 'pair programmer' producing human-style mistakes. strength: medium
Explicit premises:
Implicit premises:
Inferences:

Narratives

Questions addressed

Gaps

Related documents