https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88362
Bug ID: 88362 Summary: attribute aligned silently ignored on C++ references Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: msebor at gcc dot gnu.org Target Milestone: --- GCC honors the aligned attribute in just two of the three definitions below: it silently ignores it for the reference. Clang aligns all three objects on the same 64-byte boundary. $ cat t.C && gcc -O2 -S -Wall -fdump-tree-optimized=/dev/stdout t.C __attribute__ ((aligned (64))) int i = 123; // 64-byte aligned int __attribute__ ((aligned (64))) int *p = &i; // 64-byte aligned pointer __attribute__ ((aligned (64))) int &r = i; // 4-byte aligned reference int fi (void) { return alignof (i); } int fp (void) { return alignof (p); } int fr (void) { return alignof (r); } ;; Function fi (_Z2fiv, funcdef_no=0, decl_uid=2301, cgraph_uid=1, symbol_order=3) fi () { <bb 2> [local count: 1073741824]: return 64; } ;; Function fp (_Z2fpv, funcdef_no=4, decl_uid=2303, cgraph_uid=2, symbol_order=4) fp () { <bb 2> [local count: 1073741824]: return 64; } ;; Function fr (_Z2frv, funcdef_no=2, decl_uid=2305, cgraph_uid=3, symbol_order=5) fr () { <bb 2> [local count: 1073741824]: return 4; }