https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91043
--- Comment #23 from Richard Biener <rguenth at gcc dot gnu.org> --- (In reply to Hanoch Haim from comment #22) > > "Of course it does, because without aligning the container you cannot have > aligned members. Maximum alignment always propagates outwards." > > Sorry, your answer is still not clear, so let give a short example > In this case there is a discrepancy betwean two gcc modules > > 1. The module that generates the code think that it is aligned > (CCPortLatency) > 2. However the linker puts it in a none aligned location > > > " > class CTimeHistogram { > > } __rte_cache_aligned; > > class CCPortLatency { > public: > CTimeHistogram m_hist; > }; > class Root { > > CCPortLatency port; > > } __rte_cache_aligned; > > static Root root; > " > > In this case can I expect root.port to be aligned because its child (m_hist) > was defined as aligned and it propogate? Or should I explicitly ask both to > be aligned? Yes, for class CTimeHistogram { } __attribute__((aligned(64))); class CCPortLatency { public: CTimeHistogram m_hist; }; class Root { CCPortLatency port; }; static Root root; 'root' will be aligned to 64 bytes. This is also what you can easily observe when inspecting the ELF object: Section Headers: [Nr] Name Type Address Offset Size EntSize Flags Link Info Align ... [ 3] .bss NOBITS 0000000000000000 00000040 0000000000000040 0000000000000000 WA 0 0 64 Symbol table '.symtab' contains 8 entries: Num: Value Size Type Bind Vis Ndx Name ... 5: 0000000000000000 64 OBJECT LOCAL DEFAULT 3 _ZL4root compiled without optimization since root is unused and will otherwise be eliminated.