From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 720953858D1E; Fri, 24 Mar 2023 18:20:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 720953858D1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1679682040; bh=/hXU24HNTepBTsUJA9QduJrNpu7EtWlR6rcYn/zDHhI=; h=From:To:Subject:Date:In-Reply-To:References:From; b=CBcYCH60Hhxsm0mLgYyf9wuRdL2p1dEplXhRFa4NldVXrLLFHKABEprHBE5wm//qw 3mCl5a71uA/0DuE5x/HWDg60mATDXTrD49CF/sDKI3MVJH6FPvTTY6KLOUProEYpIl i6HMMHpR4WkDRq31N8xRkIBO7Wvgl2qjKyWH/E4c= From: "malat at debian dot org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/109175] error: 'void* __builtin_memset(void*, int, long unsigned int)' writing 4 or more bytes into a region of size 0 overflows the destination [-Werror=stringop-overflow=] Date: Fri, 24 Mar 2023 18:20:39 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: diagnostic, needs-reduction X-Bugzilla-Severity: normal X-Bugzilla-Who: malat at debian dot org 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: Message-ID: In-Reply-To: References: 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D109175 --- Comment #5 from Mathieu Malaterre --- c-reduce(d) ugly version: % cat demo3.cc struct d { using b =3D float &; }; template using c =3D d::b; struct e { using b =3D c; }; template struct j; template using h =3D typename j::b; template struct p; template struct p<0, k, l...> { using b =3D k; = }; template class m; template struct aa { aa(n t) : o(t) {} static n ab(aa t) { return t.o; } n o; }; template struct q; template struct q : q<1, s...>, aa { q(n t, s... ac) : q<1, s...>(ac...), aa(t) {} }; template struct q : aa { q(n t) : aa(t) {} }; template class m : public q<0, ad, ae> { public: m(ad t, ae ac) : q<0, ad, ae>(t, ac) {} }; template struct j> { using b =3D typename p::b; }; template n ag(q t) { return q::ab(t); } template h> ai(m t) { return ag(= t); } class u { struct aj { using b =3D float *; }; public: using ak =3D aj::b; u(ak t, int) : al(t, long()) {} ak w() { return ai<0>(al); } m al; }; struct x : u { using u::u; }; class y { x al; public: using ak =3D u::ak; using am =3D int; template y(an t, am ac) : al(t, ac) {} e::b operator[](long t) { return z()[t]; } ak z() { return al.w(); } }; void *ao(); template ap *aq(long t) { if (t) return nullptr; return static_cast(ao()); } template using ar =3D y; template ar as(long t, void *) { return ar(aq(t), int()); } template ar as(long t) { return as(t, nullptr); } float v; void at(long t) { long a =3D sizeof(0), i =3D 0; auto b =3D as(t); for (; i < a; ++i) b[i] =3D v; for (; i < t; ++i) b[i] =3D 0.0f; } % /usr/lib/gcc-snapshot/bin/g++ -Wall -O2 -o t.o -c demo3.cc demo3.cc: In function 'void at(long int)': demo3.cc:79:10: warning: 'void* __builtin_memset(void*, int, long unsigned int)' writing 4 or more bytes into a region of size 0 overflows the destina= tion [-Wstringop-overflow=3D] 79 | b[i] =3D 0.0f; cc1plus: note: destination object is likely at address zero=