public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c++/100309] New: [11 regression] false positive -Wstringop-overflow/stringop-overread/array-bounds on reinterpret_cast'd integers @ 2021-04-28 8:27 sciresm.gccbugzilla at gmail dot com 2021-04-28 8:38 ` [Bug c++/100309] " harald at gigawatt dot nl ` (2 more replies) 0 siblings, 3 replies; 4+ messages in thread From: sciresm.gccbugzilla at gmail dot com @ 2021-04-28 8:27 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100309 Bug ID: 100309 Summary: [11 regression] false positive -Wstringop-overflow/stringop-overread/array-bounds on reinterpret_cast'd integers Product: gcc Version: 11.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: sciresm.gccbugzilla at gmail dot com Target Milestone: --- Created attachment 50697 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50697&action=edit Minimal test case code. Bug occurs in GCC 11.1.0, but none of the 10.x releases. It appears that GCC is now inferring a size of 0 when doing reinterpret_cast<void*>(ConstantInteger); when doing std::memcpy/std::memset to/from the result pointers, bogus warnings are emitted about reading/writing to regions of zero size. My target is an embedded system with a fixed memory layout; I have been using constexpr uintptr_t/size_ts's to describe the memory regions, and correspondingly calls to set or copy memory regions are now emitting bogus warnings. I have made an example minimal test case here (also attached): https://godbolt.org/z/WPaGY8eaz Relevant errors (compiling with -O -Werror): void StringopOverread() { // error: 'void* memset(void*, int, size_t)' writing 16 bytes into a region of size 0 overflows the destination [-Werror=stringop-overflow=] std::memset(reinterpret_cast<void *>(0xCAFEBABE), 0xCC, 0x10); } void StringopOverflow2(const void *src) { // error: 'void* memcpy(void*, const void*, size_t)' writing 16 bytes into a region of size 0 overflows the destination [-Werror=stringop-overflow=] std::memcpy(reinterpret_cast<void *>(0xCAFEBABE), src, 0x10); } void StringopOverread(void *dst) { // error: 'void* memcpy(void*, const void*, size_t)' reading 16 bytes from a region of size 0 [-Werror=stringop-overread] std::memcpy(dst, reinterpret_cast<void *>(0xCAFEBABE), 0x10); } ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/100309] [11 regression] false positive -Wstringop-overflow/stringop-overread/array-bounds on reinterpret_cast'd integers 2021-04-28 8:27 [Bug c++/100309] New: [11 regression] false positive -Wstringop-overflow/stringop-overread/array-bounds on reinterpret_cast'd integers sciresm.gccbugzilla at gmail dot com @ 2021-04-28 8:38 ` harald at gigawatt dot nl 2021-04-28 9:30 ` [Bug c++/100309] [11/12 " rguenth at gcc dot gnu.org 2021-04-28 16:11 ` [Bug middle-end/100309] " msebor at gcc dot gnu.org 2 siblings, 0 replies; 4+ messages in thread From: harald at gigawatt dot nl @ 2021-04-28 8:38 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100309 Harald van Dijk <harald at gigawatt dot nl> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |harald at gigawatt dot nl --- Comment #1 from Harald van Dijk <harald at gigawatt dot nl> --- This is a duplicate of bug 99578. ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/100309] [11/12 regression] false positive -Wstringop-overflow/stringop-overread/array-bounds on reinterpret_cast'd integers 2021-04-28 8:27 [Bug c++/100309] New: [11 regression] false positive -Wstringop-overflow/stringop-overread/array-bounds on reinterpret_cast'd integers sciresm.gccbugzilla at gmail dot com 2021-04-28 8:38 ` [Bug c++/100309] " harald at gigawatt dot nl @ 2021-04-28 9:30 ` rguenth at gcc dot gnu.org 2021-04-28 16:11 ` [Bug middle-end/100309] " msebor at gcc dot gnu.org 2 siblings, 0 replies; 4+ messages in thread From: rguenth at gcc dot gnu.org @ 2021-04-28 9:30 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100309 Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |diagnostic Summary|[11 regression] false |[11/12 regression] false |positive |positive |-Wstringop-overflow/stringo |-Wstringop-overflow/stringo |p-overread/array-bounds on |p-overread/array-bounds on |reinterpret_cast'd integers |reinterpret_cast'd integers Target Milestone|--- |11.2 ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug middle-end/100309] [11/12 regression] false positive -Wstringop-overflow/stringop-overread/array-bounds on reinterpret_cast'd integers 2021-04-28 8:27 [Bug c++/100309] New: [11 regression] false positive -Wstringop-overflow/stringop-overread/array-bounds on reinterpret_cast'd integers sciresm.gccbugzilla at gmail dot com 2021-04-28 8:38 ` [Bug c++/100309] " harald at gigawatt dot nl 2021-04-28 9:30 ` [Bug c++/100309] [11/12 " rguenth at gcc dot gnu.org @ 2021-04-28 16:11 ` msebor at gcc dot gnu.org 2 siblings, 0 replies; 4+ messages in thread From: msebor at gcc dot gnu.org @ 2021-04-28 16:11 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100309 Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Component|c++ |middle-end CC| |msebor at gcc dot gnu.org Status|UNCONFIRMED |RESOLVED Resolution|--- |DUPLICATE --- Comment #2 from Martin Sebor <msebor at gcc dot gnu.org> --- Thus resolved as a dupe. *** This bug has been marked as a duplicate of bug 99578 *** ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-04-28 16:11 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2021-04-28 8:27 [Bug c++/100309] New: [11 regression] false positive -Wstringop-overflow/stringop-overread/array-bounds on reinterpret_cast'd integers sciresm.gccbugzilla at gmail dot com 2021-04-28 8:38 ` [Bug c++/100309] " harald at gigawatt dot nl 2021-04-28 9:30 ` [Bug c++/100309] [11/12 " rguenth at gcc dot gnu.org 2021-04-28 16:11 ` [Bug middle-end/100309] " msebor 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).