Reducing MISRA violations in LLM-generated code by 83%: An empirical study with static analysis verification

preprint OA: closed
Full text JSON View at publisher
Full text 11,650 characters · extracted from preprint-html · click to expand
Reducing MISRA violations in LLM-generated code by 83%: An empirical study with static analysis verification | Research Square window.SnipcartSettings = { analytics: { enabled: false } }; (function() { var accessVector = localStorage.getItem('access_vector') || ''; window.dataLayer = window.dataLayer || []; if (accessVector) { window.dataLayer.push({ user: { profile: { profileInfo: { snid: accessVector } } } }); } })(); (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);})(window,document,'script','dataLayer','GTM-K279D39R'); Browse Preprints In Review Journals COVID-19 Preprints AJE Video Bytes Research Tools Research Promotion AJE Professional Editing AJE Rubriq About Preprint Platform In Review Editorial Policies Our Team Advisory Board Help Center Sign In Submit a Preprint Cite Share Download PDF Research Article Reducing MISRA violations in LLM-generated code by 83%: An empirical study with static analysis verification Mariusz Woloszyn, Leszek Jerzy Raszka This is a preprint; it has not been peer reviewed by a journal. https://doi.org/ 10.21203/rs.3.rs-8123173/v1 This work is licensed under a CC BY 4.0 License Status: Posted Version 1 posted You are reading this latest preprint version Abstract Large Language Models (LLMs) are increasingly used for C++ code generation, yet their ability to satisfy Motor Industry Software Reliability Association (MISRA) C++:2023 guidelines at scale remains unclear. This study conducts a controlled before–after, repeated-measures study on 26 C++ tasks, evaluating four models with 20 runs per condition. Compiled outputs are checked with a complete MISRA C++:2023 ruleset. Verbose rule texts are distilled into compact, actionable Top-k instruction packs (k=3,5,10) targeting each model’s most frequent violations. Primary outcomes are violations per thousand lines of code (KLOC), compile rate, and pass rate. At baseline, models cluster at 23–29 violations/KLOC, dominated by an advisory rule discouraging standard integer type names. Adding Top-k instructions reduces violations by 44–83% across models (paired permutation tests, all p < 0.01); GPT-5 and o3 reach 3.9–4.5 violations/KLOC. Functional impacts are small overall; two conditions show significant pass-rate declines (GPT-4.1/Top-3, o3/Top-10). Improvements spill over to non-targeted rules. Compact, model-aware MISRA prompts therefore offer a practical path to safer C++ generation with limited functional cost when scoped appropriately. However, full verification still requires dedicated compliance tooling to detect residual issues, quantify results for certification, and produce auditable evidence for regulators. Practitioners should adopt a step-up strategy, start with Top-3 or Top-5 rules, monitor compile and pass rates, and expand only when stable. Study artifacts are released to enable replication and reuse. Software Engineering Large language models Code generation MISRA Static code analysis Safety-critical software Software quality Full Text Additional Declarations The authors declare potential competing interests as follows: Both authors have paid professional relationships with Parasoft. Parasoft develops the C/C++test tool used in this study. No other competing interests are declared. Cite Share Download PDF Status: Posted Version 1 posted You are reading this latest preprint version Research Square lets you share your work early, gain feedback from the community, and start making changes to your manuscript prior to peer review in a journal. As a division of Research Square Company, we’re committed to making research communication faster, fairer, and more useful. We do this by developing innovative software and high quality services for the global research community. Our growing team is made up of researchers and industry professionals working together to solve the most critical problems facing scientific publishing. Also discoverable on Platform About Our Team In Review Editorial Policies Advisory Board Help Center Resources Author Services Accessibility API Access RSS feed Manage Cookie Preferences © Research Square 2026 | ISSN 2693-5015 (online) Privacy Policy Terms of Service Do Not Sell My Personal Information {"props":{"pageProps":{"initialData":{"identity":"rs-8123173","acceptedTermsAndConditions":true,"allowDirectSubmit":true,"archivedVersions":[],"articleType":"Research Article","associatedPublications":[],"authors":[{"id":548217530,"identity":"1e32d3fe-eb29-4011-8306-5346ad893567","order_by":0,"name":"Mariusz Woloszyn","email":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZAAAAAyAQMAAABI0h/eAAAABlBMVEX///8AAABVwtN+AAAACXBIWXMAAA7EAAAOxAGVKw4bAAABHUlEQVRIie2Qv0vDQBTHXziIywtdLxT9D4SDgywK/VdyS7IUl+4hJZAsimtF/B+EgnPCgS6RrgG7RCFTh4JLhxuMSQpFE7s63Gf5wuN9eD8ANJp/StoGCZsYddVRX+sPxWgVuw2wr48P6xSWHlHOk9dSogqAvczn5U7JK/4WVduduqQTIOV78Vtxcp9JKzaB5VnEEeXMWT/zu5vYowgm59MeJfVAWiGCU4h4DFSKp8LlYIUyQEBz3KesKqgXo41i75gUy4X/aSgl6aBS1FPQZI1C0ZXikU45QfMvpYLsIXZx0tyS+mKxzmfk9PsWOXDLyiPbjQrO7CTK6o9diNv7ZGls6o+dJFH50aPswS4jALqvkeH2Q4IDRaPRaDQtXwutaB1AiAj0AAAAAElFTkSuQmCC","orcid":"https://orcid.org/0009-0009-1323-781X","institution":"Parasoft Corporation","correspondingAuthor":true,"prefix":"","firstName":"Mariusz","middleName":"","lastName":"Woloszyn","suffix":""},{"id":548217531,"identity":"f73c35fc-1588-4fa7-a996-ae08919a05e4","order_by":1,"name":"Leszek Jerzy Raszka","email":"","orcid":"","institution":"Parasoft Corporation","correspondingAuthor":false,"prefix":"","firstName":"Leszek","middleName":"Jerzy","lastName":"Raszka","suffix":""}],"badges":[],"createdAt":"2025-11-15 16:07:24","currentVersionCode":1,"declarations":{"humanSubjects":false,"vertebrateSubjects":false,"conflictsOfInterestStatement":true,"humanSubjectEthicalGuidelines":false,"humanSubjectConsent":false,"humanSubjectClinicalTrial":false,"humanSubjectCaseReport":false,"vertebrateSubjectEthicalGuidelines":false},"doi":"10.21203/rs.3.rs-8123173/v1","doiUrl":"https://doi.org/10.21203/rs.3.rs-8123173/v1","draftVersion":[],"editorialEvents":[],"editorialNote":"","failedWorkflow":false,"files":[{"id":96913082,"identity":"1e5481c6-c195-43fc-897b-c6c800ded12a","added_by":"auto","created_at":"2025-11-27 13:51:50","extension":"pdf","order_by":1,"title":"","display":"","copyAsset":false,"role":"manuscript-pdf","size":471132,"visible":true,"origin":"","legend":"","description":"","filename":"Paper.pdf","url":"https://assets-eu.researchsquare.com/files/rs-8123173/v1_covered_8b7e3883-2cd2-46d2-a72c-40f77ec1c583.pdf"}],"financialInterests":"The authors declare potential competing interests as follows: Both authors have paid professional relationships with Parasoft. Parasoft develops the C/C++test tool used in this study. No other competing interests are declared.","formattedTitle":"\u003cp\u003eReducing MISRA violations in LLM-generated code by 83%: An empirical study with static analysis verification\u003c/p\u003e","fulltext":[],"fulltextSource":"","fullText":"","funders":[],"hasAdminPriorityOnWorkflow":false,"hasManuscriptDocX":false,"hasOptedInToPreprint":true,"hasPassedJournalQc":"","hasAnyPriority":true,"hideJournal":true,"highlight":"","institution":"Parasoft Corporation","isAcceptedByJournal":false,"isAuthorSuppliedPdf":true,"isDeskRejected":"","isHiddenFromSearch":false,"isInQc":false,"isInWorkflow":false,"isPdf":true,"isPdfUpToDate":true,"isWithdrawnOrRetracted":false,"journal":{"display":true,"email":"[email protected]","identity":"researchsquare","isNatureJournal":false,"hasQc":true,"allowDirectSubmit":true,"externalIdentity":"","sideBox":"","snPcode":"","submissionUrl":"/submission","title":"Research Square","twitterHandle":"researchsquare","acdcEnabled":true,"dfaEnabled":false,"editorialSystem":"","reportingPortfolio":"","inReviewEnabled":false,"inReviewRevisionsEnabled":true},"keywords":"Large language models, Code generation, MISRA, Static code analysis, Safety-critical software, Software quality","lastPublishedDoi":"10.21203/rs.3.rs-8123173/v1","lastPublishedDoiUrl":"https://doi.org/10.21203/rs.3.rs-8123173/v1","license":{"name":"CC BY 4.0","url":"https://creativecommons.org/licenses/by/4.0/"},"manuscriptAbstract":"\u003cp\u003eLarge Language Models (LLMs) are increasingly used for C++ code generation, yet their ability to satisfy Motor Industry Software Reliability Association (MISRA) C++:2023 guidelines at scale remains unclear. This study conducts a controlled before–after, repeated-measures study on 26 C++ tasks, evaluating four models with 20 runs per condition. Compiled outputs are checked with a complete MISRA C++:2023 ruleset. Verbose rule texts are distilled into compact, actionable Top-k instruction packs (k=3,5,10) targeting each model’s most frequent violations. Primary outcomes are violations per thousand lines of code (KLOC), compile rate, and pass rate.\u003c/p\u003e\n\u003cp\u003eAt baseline, models cluster at 23–29 violations/KLOC, dominated by an advisory rule discouraging standard integer type names. Adding Top-k instructions reduces violations by 44–83% across models (paired permutation tests, all p \u0026lt; 0.01); GPT-5 and o3 reach 3.9–4.5 violations/KLOC. Functional impacts are small overall; two conditions show significant pass-rate declines (GPT-4.1/Top-3, o3/Top-10). Improvements spill over to non-targeted rules.\u003c/p\u003e\n\u003cp\u003eCompact, model-aware MISRA prompts therefore offer a practical path to safer C++ generation with limited functional cost when scoped appropriately. However, full verification still requires dedicated compliance tooling to detect residual issues, quantify results for certification, and produce auditable evidence for regulators. Practitioners should adopt a step-up strategy, start with Top-3 or Top-5 rules, monitor compile and pass rates, and expand only when stable. Study artifacts are released to enable replication and reuse.\u003c/p\u003e","manuscriptTitle":"Reducing MISRA violations in LLM-generated code by 83%: An empirical study with static analysis verification","msid":"","msnumber":"","nonDraftVersions":[{"code":1,"date":"2025-11-25 14:19:13","doi":"10.21203/rs.3.rs-8123173/v1","editorialEvents":[{"type":"communityComments","content":0}],"status":"published","journal":{"display":true,"email":"[email protected]","identity":"researchsquare","isNatureJournal":false,"hasQc":true,"allowDirectSubmit":true,"externalIdentity":"","sideBox":"","snPcode":"","submissionUrl":"/submission","title":"Research Square","twitterHandle":"researchsquare","acdcEnabled":true,"dfaEnabled":false,"editorialSystem":"","reportingPortfolio":"","inReviewEnabled":false,"inReviewRevisionsEnabled":true}}],"origin":"","ownerIdentity":"c7c22b9b-a0d8-4782-adf8-623916cb9e2f","owner":[],"postedDate":"November 25th, 2025","published":true,"recentEditorialEvents":[],"rejectedJournal":[],"revision":"","amendment":"","status":"posted","subjectAreas":[{"id":58332863,"name":"Software Engineering"}],"tags":[],"updatedAt":"2025-11-25T14:19:13+00:00","versionOfRecord":[],"versionCreatedAt":"2025-11-25 14:19:13","video":"","vorDoi":"","vorDoiUrl":"","workflowStages":[]},"version":"v1","identity":"rs-8123173","journalConfig":"researchsquare"},"__N_SSP":true},"page":"/article/[identity]/[[...version]]","query":{"redirect":"/article/rs-8123173","identity":"rs-8123173","version":["v1"]},"buildId":"8U1c8b4HqxoKbykW_rLl7","isFallback":false,"isExperimentalCompile":false,"dynamicIds":[84888],"gssp":true,"scriptLoader":[]}

Text is read by the "Ask this paper" AI Q&A widget below. Extraction quality varies by source — PMC NXML preserves structure cleanly, OA-HTML may include some navigation residue, and OA-PDF can have broken hyphenation. The publisher copy (via DOI) is the canonical version.

My notes (saved in your browser only)

Ask this paper AI returns verbatim quotes from the full text · source: preprint-html

Answers must be backed by verbatim quotes from this paper's full text. Hallucinated quotes are dropped automatically; if no verbatim passage answers the question, we say so. How this works

Citation neighborhood (no data yet)

We don't have any in-corpus citations linked to this paper yet. This is a recent paper (2025) — citers typically take a year or two to land, and the OpenAlex reference graph may still be filling in.

Source provenance

europepmc
last seen: 2026-05-20T01:45:00.602351+00:00