C99 Designated Initializers Misplace Struct Array Elements in EmbeddedC
0 reputation · 15 Jan 2025, 16:34 UTC
Problem Statement
EmbeddedC claims support for C99 designated initializers, yet older releases (e.g., 1.9.x) have been observed to generate object code that misplaces array elements inside structs. The compiler may accept the syntax and emit a warning, but the resulting memory layout diverges from the C99 standard, potentially corrupting runtime data.
The goal is to determine whether a given EmbeddedC version correctly emits the expected offsets for struct members when designated initializers are used on array elements. Constraints include specific compiler flags, target MCU architecture, and the necessity of inspecting both assembly output and run‑time memory content on actual hardware or an accurate simulator.
Uncertainty remains about the behavior across releases, especially regarding any patches introduced in 2.0+ and the influence of compile‑time options.
Key Questions
- Does EmbeddedC 2.0+ correctly generate offsets for designated initializers on structs containing arrays?
- Which compiler flags affect the code generation for this feature, and how do they alter the memory layout?
- Is there a documented bug or issue tracker entry that explains the misplacement of array elements in older releases?