https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109435
Bug ID: 109435 Summary: [MIPS64R6] Typedef struct alignment returns incorrect results Product: gcc Version: 10.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: other Assignee: unassigned at gcc dot gnu.org Reporter: jovan.dmitrovic at syrmia dot com Target Milestone: --- Consider the following testcase: #include<stdio.h> typedef struct uint8 { unsigned v[8]; } uint8 __attribute__ ((aligned(128))); unsigned callee(int x, uint8 a) { return a.v[0]; } uint8 identity(uint8 in) { return in; } int main() { uint8 vec = {1, 2, 3, 4, 5, 6, 7, 8}; printf("res1: %d\n", callee(99, identity(vec))); uint8 temp = identity(vec); printf("res2: %d\n", callee(99, temp)); } When this code is compiled for MIPS64 R6, output is as follows: res1: 3 res2: 1 However, when aligned attribute is removed from the testcase, res1 and res2 become 1, which are values that were expected in the first place. Furthermore, this bug is reproducible only if there is a unused argument x in function callee. Adding more arguments or switching their places also produces expected values. Type of x doesn't seem to impact the result.