From patchwork Thu Dec 1 13:27:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prathamesh Kulkarni X-Patchwork-Id: 86055 Delivered-To: patch@linaro.org Received: by 10.182.112.6 with SMTP id im6csp872889obb; Thu, 1 Dec 2016 05:28:17 -0800 (PST) X-Received: by 10.84.217.216 with SMTP id d24mr84723893plj.101.1480598897674; Thu, 01 Dec 2016 05:28:17 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id e16si215461pli.77.2016.12.01.05.28.17 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Dec 2016 05:28:17 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-443209-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-443209-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-443209-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; q= dns; s=default; b=CncLLi00r5IQsHQ2Xm+2a5uBDFbtrY0FIc4GXE2SvekDqH 1pP/PQF/yUJWJYcFuL2WS3+VkRorZF27mJz3du0nI9giIVOb8+sHwaWjl4fE2cun z1tLniY7w4beWy9gsZgxXXdRzJThvoIgEH9YGE/XYI2hCWV/1ScgJyIiLzAdM= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; s= default; bh=9EjxGP+WR8KPyswvGbtOVal+YJY=; b=psPYuwP4jNPvsSH3blDM afZQc3m5XUiCQwaFwRFcYV0jAfwIKXXwxIfiq47h7xzVIqhesEzw9CXMes0ehmzf nOFsmXfSOvkrKeukvrMd9H/IPKj5qPBG9gOHQr0nV78HbjAAMKnS9K+9lPcSjq6P iGVzFHb8UoHWRdJ5uJLKCrU= Received: (qmail 130859 invoked by alias); 1 Dec 2016 13:27:49 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 130138 invoked by uid 89); 1 Dec 2016 13:27:48 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=no version=3.3.2 spammy=prathameshkulkarnilinaroorg, prathamesh.kulkarni@linaro.org, Guard, 2016-12-01 X-HELO: mail-io0-f175.google.com Received: from mail-io0-f175.google.com (HELO mail-io0-f175.google.com) (209.85.223.175) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 01 Dec 2016 13:27:36 +0000 Received: by mail-io0-f175.google.com with SMTP id m5so284642095ioe.3 for ; Thu, 01 Dec 2016 05:27:36 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=KqFjG0jn5ol3xMg7veFTU+JDsowhTlo/efdVFGwlujQ=; b=imJG93B/99E4XDthMj9+pH4MPvlKEVcWuZFizwm1+tCQzMaNVcR1YrzXp1LRbauS67 0+4gFXnqbMgoltX14CnuhslClgZyj3D2Yk86UFt/K5bGc/L7MkEtSzqUmyXFJR3pAOrO GJDcYtazbCegHAlDj6mVnWudYw70DHmz0sYW49LgxRSzbRYT1gAxJie5tJiOwbFDUG+A 9iRibjVP/NkQ+ooTqRkdr9TkU6iX3VSqSp7Vxx9iGluvhLgh1BSa8DAWhdoBHCEoo5Uc yrAo5nFtm2gQRa2ynKv5O6i+h51yM8LzPfijkic9Lt/PM54dVEPynA7mD66+abeEZ/ZH mhLw== X-Gm-Message-State: AKaTC03273O5SDAcJrrWcBOIQndvxCaqRib48UVqI6u/63i0QHeyAeGt91zyJbeMF4BZT26tsaPB3zY2ukC7c9XC X-Received: by 10.36.215.197 with SMTP id y188mr33367123itg.71.1480598854977; Thu, 01 Dec 2016 05:27:34 -0800 (PST) MIME-Version: 1.0 Received: by 10.107.47.92 with HTTP; Thu, 1 Dec 2016 05:27:34 -0800 (PST) From: Prathamesh Kulkarni Date: Thu, 1 Dec 2016 18:57:34 +0530 Message-ID: Subject: PR78629 To: gcc Patches , Richard Biener X-IsSubscribed: yes Hi Richard, I tested your fix for the patch with ubsan stage-1 built gcc, and it fixes the error. Is it OK to commit if bootstrap+test passes on x86_64-unknown-linux-gnu ? Thanks, Prathamesh 2016-12-01 Richard Biener Prathamesh Kulkarni PR middle-end/78629 * vec.h (vec::quick_grow_cleared): Guard call to memset if len-oldlen != 0. (vec::safe_grow_cleared): Likewise. diff --git a/gcc/vec.h b/gcc/vec.h index 14fb2a6..aa93411 100644 --- a/gcc/vec.h +++ b/gcc/vec.h @@ -1092,8 +1092,10 @@ inline void vec::quick_grow_cleared (unsigned len) { unsigned oldlen = length (); + size_t sz = sizeof (T) * (len - oldlen); quick_grow (len); - memset (&(address ()[oldlen]), 0, sizeof (T) * (len - oldlen)); + if (sz != 0) + memset (&(address ()[oldlen]), 0, sz); } @@ -1605,8 +1607,10 @@ inline void vec::safe_grow_cleared (unsigned len MEM_STAT_DECL) { unsigned oldlen = length (); + size_t sz = sizeof (T) * (len - oldlen); safe_grow (len PASS_MEM_STAT); - memset (&(address ()[oldlen]), 0, sizeof (T) * (len - oldlen)); + if (sz != 0) + memset (&(address ()[oldlen]), 0, sz); }