public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "alwin.zhang at sap dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c/116357] New: The item's address of the array is not correct if aligned is used Date: Tue, 13 Aug 2024 05:40:12 +0000 [thread overview] Message-ID: <bug-116357-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116357 Bug ID: 116357 Summary: The item's address of the array is not correct if aligned is used Product: gcc Version: 10.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: alwin.zhang at sap dot com Target Milestone: --- Created attachment 58922 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58922&action=edit Test code to reproduce the issue. The item's address of the array is not correct if aligned is used on the type of array item. The debug version (without gcc optimization) doesn't have the issue, but if we enable optimization like -O1/O2, all the items of the array are using the same address. Attached file is the test code to reproduce the issue. This issue could be reproduced from gcc 7.1 to latest 14.2. From following asm code we can see that the items of the array are using the same address. C code is - ------------------ u64 * l1; u64 * l2; void align_test(chn_t * p) { l1 = (u64*)(&(p->lock[0])); l2 = (u64*)(&(p->lock[99])); printf("addr is [0]=%llu, [99]=%llu\n", l1, l2); } ------------------ asm code is - ------------------ align_test: sub rsp, 8 mov rsi, rdi mov QWORD PTR l1[rip], rdi mov QWORD PTR l2[rip], rdi mov rdx, rdi mov edi, OFFSET FLAT:.LC0 mov eax, 0 call printf add rsp, 8 ret ------------------ Please download the test code and compile with gcc optimization like -O2 to check the issue. Bug 65204 appears to be the same as this issue, but it's resolved. Thanks!
next reply other threads:[~2024-08-13 5:40 UTC|newest] Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-08-13 5:40 alwin.zhang at sap dot com [this message] 2024-08-13 6:43 ` [Bug tree-optimization/116357] [12/13/14/15 Regression] " pinskia at gcc dot gnu.org 2024-08-13 6:49 ` pinskia at gcc dot gnu.org 2024-08-14 1:34 ` alwin.zhang at sap dot com 2024-08-15 5:18 ` alwin.zhang at sap dot com 2024-09-17 8:36 ` [Bug c/116357] " rguenth at gcc dot gnu.org 2024-09-19 1:58 ` alwin.zhang at sap dot com
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-116357-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).