https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94338
--- Comment #5 from huaixin chang <huaixin....@alibaba-inc.com> --- (In reply to Richard Biener from comment #2) > I think the testcase is ill-formed and should be diagnosed in some form. > IIRC there's some documented behavior (that's not implemented) that > __aligned__ > only increases alignment unless __packed__ is used. With __packed__ the > testcase behaves as expected I think. > > Note __attribute__((__aligned__(4))) applies to 'A', not its type. Yes, I missed this and quoted wrong document for this case. > > Not sure if behavior changes if you use a typedef that is aligned to 4. If a use a typedef that is aligned to 4 like this: typedef struct { long a __attribute__((__aligned__(128))); long b __attribute__((__aligned__(128))); } foo __attribute__((__aligned(4))); foo A; Or align variable A to 4 only like this: typedef struct { long a __attribute__((__aligned__(128))); long b __attribute__((__aligned__(128))); } foo; foo A __attribute__((__aligned(4))); I will get warned while compiling and alignment is as expected.