public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug middle-end/87296] [8/9/10 Regression] -Wstringop-overflow false positive due to using MEM_REF type of &MEM [not found] <bug-87296-4@http.gcc.gnu.org/bugzilla/> @ 2020-04-18 18:49 ` law at redhat dot com 2020-10-26 18:31 ` [Bug middle-end/87296] [8/9/10/11 " mostlyaspambox at protonmail dot com ` (2 subsequent siblings) 3 siblings, 0 replies; 4+ messages in thread From: law at redhat dot com @ 2020-04-18 18:49 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87296 Jeffrey A. Law <law at redhat dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |sbergman at redhat dot com --- Comment #8 from Jeffrey A. Law <law at redhat dot com> --- *** Bug 92893 has been marked as a duplicate of this bug. *** ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug middle-end/87296] [8/9/10/11 Regression] -Wstringop-overflow false positive due to using MEM_REF type of &MEM [not found] <bug-87296-4@http.gcc.gnu.org/bugzilla/> 2020-04-18 18:49 ` [Bug middle-end/87296] [8/9/10 Regression] -Wstringop-overflow false positive due to using MEM_REF type of &MEM law at redhat dot com @ 2020-10-26 18:31 ` mostlyaspambox at protonmail dot com 2021-02-12 0:32 ` msebor at gcc dot gnu.org 2021-02-12 0:34 ` msebor at gcc dot gnu.org 3 siblings, 0 replies; 4+ messages in thread From: mostlyaspambox at protonmail dot com @ 2020-10-26 18:31 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87296 mostlyaspambox at protonmail dot com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |mostlyaspambox at protonmail dot c | |om --- Comment #9 from mostlyaspambox at protonmail dot com --- I think I've also hit this or a variation of it with the following reproducer: ``` #include <string.h> #include <algorithm> #include <assert.h> #include <array> struct Base1 { char arr[5]; }; struct Base2 { char arr[25]; }; struct A : Base1, Base2 { }; extern const char* str; void f(A& a) { Base1& base1 = a; std::fill(std::begin(base1.arr), std::end(base1.arr), ' '); Base2& base2 = a; strncpy(reinterpret_cast<char*>(&base2), str, 6); } int main() { A a{}; f(a); } ``` If `a` is created inside `f` instead of passed in by reference, there is no error. When compiled with `g++ -std=c++11 -O2 -Wall -Wextra -fno-strict-aliasing -fwrapv -fno-aggressive-loop-optimizations -fsanitize=undefined` on x86-64 with gcc 8.1 this prints: test.cpp:27:12: warning: 'char* strncpy(char*, const char*, size_t)' writing 6 bytes into a region of size 5 overflows the destination [-Wstringop-overflow=] strncpy(reinterpret_cast<char*>(&base2), str, 6); ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ If `str` in the strncpy call is replaced with a string literal, there is the same warning unless the literal has length 6 including the null terminator. ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug middle-end/87296] [8/9/10/11 Regression] -Wstringop-overflow false positive due to using MEM_REF type of &MEM [not found] <bug-87296-4@http.gcc.gnu.org/bugzilla/> 2020-04-18 18:49 ` [Bug middle-end/87296] [8/9/10 Regression] -Wstringop-overflow false positive due to using MEM_REF type of &MEM law at redhat dot com 2020-10-26 18:31 ` [Bug middle-end/87296] [8/9/10/11 " mostlyaspambox at protonmail dot com @ 2021-02-12 0:32 ` msebor at gcc dot gnu.org 2021-02-12 0:34 ` msebor at gcc dot gnu.org 3 siblings, 0 replies; 4+ messages in thread From: msebor at gcc dot gnu.org @ 2021-02-12 0:32 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87296 Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |FIXED Target Milestone|8.5 |11.0 Status|NEW |RESOLVED Blocks| |88443 Assignee|unassigned at gcc dot gnu.org |msebor at gcc dot gnu.org --- Comment #10 from Martin Sebor <msebor at gcc dot gnu.org> --- GCC 11 no longer warns for these test cases, most likely as a result of r11-3827. Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88443 [Bug 88443] [meta-bug] bogus/missing -Wstringop-overflow warnings ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug middle-end/87296] [8/9/10/11 Regression] -Wstringop-overflow false positive due to using MEM_REF type of &MEM [not found] <bug-87296-4@http.gcc.gnu.org/bugzilla/> ` (2 preceding siblings ...) 2021-02-12 0:32 ` msebor at gcc dot gnu.org @ 2021-02-12 0:34 ` msebor at gcc dot gnu.org 3 siblings, 0 replies; 4+ messages in thread From: msebor at gcc dot gnu.org @ 2021-02-12 0:34 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87296 --- Comment #11 from Martin Sebor <msebor at gcc dot gnu.org> --- I should note: The changes are too intrusive to backport. ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-02-12 0:34 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <bug-87296-4@http.gcc.gnu.org/bugzilla/> 2020-04-18 18:49 ` [Bug middle-end/87296] [8/9/10 Regression] -Wstringop-overflow false positive due to using MEM_REF type of &MEM law at redhat dot com 2020-10-26 18:31 ` [Bug middle-end/87296] [8/9/10/11 " mostlyaspambox at protonmail dot com 2021-02-12 0:32 ` msebor at gcc dot gnu.org 2021-02-12 0:34 ` 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).