Key points are not available for this paper at this time.
While Large Language Models (LLMs) show great potential in code generation, their application in safety-critical domains is strictly constrained by mandatory standards like MISRA C. Our empirical study confirms this critical gap: state-of-the-art LLMs universally fail to comply with MISRA C criteria, and naïve self-refinement often leads to a “refinement-worsens-violation” dilemma. To address the dual challenge, we propose HI-MISRA, a Hybrid Iterative Refinement Framework. HI-MISRA tackles these challenges through two key innovations: (1) Knowledge-Enhanced Prioritized Refinement, which first applies deterministic fixes for simple violations, then guides the LLM to refine severity-prioritized batches of complex violations by injecting dynamic knowledge; and (2) Iterative Refinement with Regression Prevention, which employs a three-stage “compilation-functionality-compliance” verification pipeline to ensure that each modification yields a net improvement, while a dynamic suspension strategy prevents the refinement from getting stuck in ineffective loops. Experiments across LLMs, including GPT-5, Gemini-2.5-Flash, Claude-3.7-Sonnet, and DeepSeek-V3.1, demonstrate the superior performance of HI-MISRA. For instance, HI-MISRA achieves a 92.5% triple-pass rate (compilation, functionality, compliance) based on GPT-5, far surpassing the baseline (62.0%) at a similar cost and outperforming the best existing method (78.5% with higher costs). Experimental results offer a practical pathway for the deployment of LLMs in the safety-critical domain.
Zhang et al. (Sat,) studied this question.