public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug other/109435] New: [MIPS64R6] Typedef struct alignment returns incorrect results
@ 2023-04-06 14:04 jovan.dmitrovic at syrmia dot com
  2023-04-06 14:28 ` [Bug other/109435] " jovan.dmitrovic at syrmia dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: jovan.dmitrovic at syrmia dot com @ 2023-04-06 14:04 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-07-01  6:35 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-06 14:04 [Bug other/109435] New: [MIPS64R6] Typedef struct alignment returns incorrect results jovan.dmitrovic at syrmia dot com
2023-04-06 14:28 ` [Bug other/109435] " jovan.dmitrovic at syrmia dot com
2023-04-06 19:14 ` [Bug target/109435] overaligned structs are not passed correctly for mips64 pinskia at gcc dot gnu.org
2023-05-29 11:07 ` jovan.dmitrovic at syrmia dot com
2023-06-30  3:21 ` cvs-commit at gcc dot gnu.org
2023-07-01  6:35 ` syq at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).