From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21924 invoked by alias); 26 May 2014 12:42:52 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 21487 invoked by uid 48); 26 May 2014 12:42:46 -0000 From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/61294] [4.9 Regression] erroneous memset used with constant zero length parameter warning Date: Mon, 26 May 2014 12:42:00 -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: 4.9.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED 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: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-05/txt/msg02214.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61294 --- Comment #1 from Richard Biener --- Happens on an isolated path where GCC optimized if (len) .... memset (p, val, len); to if (len == 0) { .... memset (p, val, 0); } else { ..... memset (p, val, len); } can happen and there is no good way around that, thus it's a false positive. It's the if (grid->Points) check that is false when the compiler can compute the 'len' parameter will be zero. Maybe that helps you deciding whether it really is a false positive or not (well, yes, whether you are calling memset with len == 0, which might be valid, but we warn about it).