From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 32A183857C7B; Fri, 7 Jan 2022 13:43:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 32A183857C7B From: "egallager at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/103939] memset with sizeof in wrong place not detected ? Date: Fri, 07 Jan 2022 13:43:50 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: enhancement X-Bugzilla-Who: egallager at gcc dot gnu.org X-Bugzilla-Status: NEW 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: cc 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 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: Fri, 07 Jan 2022 13:43:50 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103939 Eric Gallager changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |egallager at gcc dot gnu.o= rg --- Comment #2 from Eric Gallager --- (In reply to Jonathan Wakely from comment #1) > The docs explain why GCC's -Wmemset-transposed-args doesn't warn: >=20 > Warn for suspicious calls to the "memset" built-in function where the > second > argument is not zero and the third argument is zero. For example, the = call > "memset (buf, sizeof buf, 0)" is diagnosed because "memset (buf, 0, siz= eof > buf)" was meant instead. The diagnostic is only emitted if the third > argument > is a literal zero. >=20 > So not warning for your case is by design. >=20 > But it probably makes sense to warn if the second argument is a sizeof > expression, whatever the value of the third argument. What if both the second and third arguments are 'sizeof' expressions?=