From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id AB8273858C60; Tue, 9 Nov 2021 02:56:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AB8273858C60 From: "tonyfettes at tonyfettes dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/103145] New: False positive of -Wstringop-overread on gcc-11 Date: Tue, 09 Nov 2021 02:56:45 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 11.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: tonyfettes at tonyfettes dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Nov 2021 02:56:45 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103145 Bug ID: 103145 Summary: False positive of -Wstringop-overread on gcc-11 Product: gcc Version: 11.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: tonyfettes at tonyfettes dot com Target Milestone: --- Hi, The following piece of code will trigger -Wstringop-overread $ cat test.c // test.c #include #define ARRAY_SIZE 4 struct func_in_t { int x; int y; }; struct example_t { int field0; int field1; int field2; int field3; int field4; }; struct example_t func(const struct func_in_t *in, const int array[ARRAY_SIZ= E]) { struct example_t out =3D {0}; return out; } int main() { int array[ARRAY_SIZE] =3D { 0, 0, 0, 0 }; struct func_in_t in =3D { .x =3D 0, .y =3D 0, }; struct example_t col =3D func(&in, array); (void) col; return 0; } $ gcc -fno-strict-aliasing -fwrapv -Wall test.c -o test=20 test.c: In function =E2=80=98main=E2=80=99: test.c:30:26: warning: =E2=80=98func=E2=80=99 reading 16 bytes from a regio= n of size 8 [-Wstringop-overread] 30 | struct example_t col =3D func(&in, array); | ^~~~~~~~~~~~~~~~ test.c:30:26: note: referencing argument 2 of type =E2=80=98const int *=E2= =80=99 test.c:19:18: note: in a call to function =E2=80=98func=E2=80=99 19 | struct example_t func(const struct func_in_t *in, const int array[ARRAY_SIZE]) { | ^~~~ $ gcc -v Using built-in specs. COLLECT_GCC=3Dgcc COLLECT_LTO_WRAPPER=3D/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: /build/gcc/src/gcc/configure --prefix=3D/usr --libdir=3D/u= sr/lib --libexecdir=3D/usr/lib --mandir=3D/usr/share/man --infodir=3D/usr/share/in= fo --with-bugurl=3Dhttps://bugs.archlinux.org/ --enable-languages=3Dc,c++,ada,fortran,go,lto,objc,obj-c++,d --with-isl --with-linker-hash-style=3Dgnu --with-system-zlib --enable-__cxa_atexit --enable-cet=3Dauto --enable-checking=3Drelease --enable-clocale=3Dgnu --enable-default-pie --enable-default-ssp --enable-gnu-indirect-function --enable-gnu-unique-object --enable-install-libiberty --enable-linker-build= -id --enable-lto --enable-multilib --enable-plugin --enable-shared --enable-threads=3Dposix --disable-libssp --disable-libstdcxx-pch --disable-libunwind-exceptions --disable-werror gdc_include_dir=3D/usr/include/dlang/gdc Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 11.1.0 (GCC)=20 It seems like a duplication of https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D101854, but I'm not sure abo= ut it since gcc gave different diagnostics (one is overread, the other is overflo= w), so I decide to submit it anyway.=