<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Kernel-Patch on ankit_kdev</title><link>https://www.ankitkdev.com/tags/kernel-patch/</link><description>Recent content in Kernel-Patch on ankit_kdev</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Mon, 04 May 2026 13:30:05 +0530</lastBuildDate><atom:link href="https://www.ankitkdev.com/tags/kernel-patch/index.xml" rel="self" type="application/rss+xml"/><item><title>C Memory Layout: Structs, Unions, and a Linux Kernel Patch</title><link>https://www.ankitkdev.com/blog/c-memory-layout/</link><pubDate>Mon, 04 May 2026 13:30:05 +0530</pubDate><guid>https://www.ankitkdev.com/blog/c-memory-layout/</guid><description>&lt;h1 id="overview">Overview&lt;/h1>
&lt;p>C memory layout looks simple in isolation: structs store fields sequentially, unions overlap memory, and flexible array members allow variable-sized trailing storage. But combining these features can create subtle layout issues.&lt;/p>
&lt;p>While working on a Linux kernel selftest, I encountered a case where a union contained multiple structures, each ending with a flexible array member at different offsets. Although the code was functionally correct, this confused the compiler into treating the union as effectively variable-sized, triggering a layout warning.&lt;/p></description></item></channel></rss>