public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "zfigura at codeweavers dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c/106904] New: Incorrect -Wstringop-overflow with partial memcpy() into a nested structure Date: Sun, 11 Sep 2022 22:47:11 +0000 [thread overview] Message-ID: <bug-106904-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106904 Bug ID: 106904 Summary: Incorrect -Wstringop-overflow with partial memcpy() into a nested structure Product: gcc Version: 12.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: zfigura at codeweavers dot com Target Milestone: --- Created attachment 53562 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53562&action=edit minimal test case I encountered a warning while trying to compile 32-bit wine 7.17 with gcc 12.2, specificially at this line here: https://source.winehq.org/git/wine.git/blob/wine-7.17:/dlls/win32u/message.c#l359 The relevant code copies a smaller structure into a larger one of a different type. (This may be a violation of aliasing rules, but adding -fno-strict-aliasing doesn't change anything.) I was able to reproduce this with a minimal test case. This is a very weird set of conditions, but I couldn't seem to reduce this test case any further. Changing the type of "ps" to "struct packed_windowpos" makes the error go away; so does changing the first argument of the memcpy to "ps". leslie@terabithia:~$ gcc --version gcc (Debian 12.2.0-1) 12.2.0 Copyright (C) 2022 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. leslie@terabithia:~$ gcc -m32 test.c -c -o test.o -Wall -O2 test.c: In function ‘func’: test.c:26:5: warning: writing 8 bytes into a region of size 4 [-Wstringop-overflow=] 26 | __builtin_memcpy(&ps->wp, &wp, sizeof(wp)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ test.c:9:9: note: destination object ‘hwnd’ of size 4 9 | int hwnd; | ^~~~
next reply other threads:[~2022-09-11 22:47 UTC|newest] Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-09-11 22:47 zfigura at codeweavers dot com [this message] 2022-09-11 22:51 ` [Bug tree-optimization/106904] " pinskia at gcc dot gnu.org 2022-09-11 22:52 ` zfigura at codeweavers dot com 2022-09-11 22:54 ` zfigura at codeweavers dot com 2022-09-13 15:30 ` [Bug tree-optimization/106904] [12/13 Regression] " pinskia at gcc dot gnu.org 2022-12-07 13:42 ` rguenth at gcc dot gnu.org 2022-12-11 13:35 ` cvs-commit at gcc dot gnu.org 2022-12-11 13:35 ` [Bug tree-optimization/106904] [12 " rguenth at gcc dot gnu.org 2022-12-11 17:40 ` zfigura at codeweavers dot com 2023-03-15 9:47 ` cvs-commit at gcc dot gnu.org 2023-03-15 10:05 ` rguenth at gcc dot gnu.org
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-106904-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).