From patchwork Fri Jun 30 08:34:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 782698 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wzVFp0xYCz9s78 for ; Fri, 30 Jun 2017 18:34:53 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="WQ28lf3B"; dkim-atps=neutral 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:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; q=dns; s=default; b=qQVIOWempNSBzZW PBoP+C3/6zS8+AlB9qcSBP39mcVJzb+cTdX5vYaT6Ds1P9D/Wf6XfEsHHRZ6eeVV Aorn0DzbESKvyAjqc2/tTCmBst2rFDs71WoMl2j5lFH8h6xC7tItrFDASj7wl7AF dYcXpi5ZThNaW36wmqbQEEF5penc= 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:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; s=default; bh=zLONxDXrZxaDUC3dLf/tA ysDhaM=; b=WQ28lf3BdH2ZGUUroSvv6N3kmMNR/d4qKYwO6uRF83A3/Gzr4xnGp zVvWVCrWlyMe2t8qkpXEIg2N12fij6oOf5oi8CzZPouNs+1f2/eO4+ShsHJx+52x LOlRPMC/PgJxVOLUWgQ1B0UXedyIfVSFCcqcT6f1U+SIFaBQchsIMg= Received: (qmail 13555 invoked by alias); 30 Jun 2017 08:34:44 -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 13540 invoked by uid 89); 30 Jun 2017 08:34:43 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.0 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-spam-relays-external:74.125.82.68, H*RU:74.125.82.68, our X-HELO: mail-wm0-f68.google.com Received: from mail-wm0-f68.google.com (HELO mail-wm0-f68.google.com) (74.125.82.68) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 30 Jun 2017 08:34:42 +0000 Received: by mail-wm0-f68.google.com with SMTP id p204so6627262wmg.1 for ; Fri, 30 Jun 2017 01:34:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=NIEtvEihY3+yLYQIpLWoGQxqGceeAPVR6uQ1lqsDf9E=; b=NyC05bvTg8N10PrU291qteLLLPhmZUtA3aQ4V9KD6IuhBmQFMXJRtD0e7Hd7dehyrK tAY3M8k6MLyaB8Va0/jWIKOcCbzbhTcT/z6ns25eCDqMUJ+STpbE3FXl3MI7cKEvMx6c 8EQgR6QUy+DXflrrl7FfcoR/AO6QIRL+39HH3N9yxRCFfE4Ll1Nd6qqE1zhXra5TlwN8 zpAR8uQX4Pcl5YW3O5ICUz+LGJpjGMsOWd87Jn1/a08oFvmHsdCEmlsPhN/wyxbqnMn0 qMUbWHYdAdJlIYFAuUOkuj5wPOmbtqJK5yjvyNpvVErC57uQPYDUfUF9XkGryryVHt/E xXGg== X-Gm-Message-State: AKS2vOxCECdpv0Xs6RNmee9W/q8A8C7FiWq4X/732iYDC5EzMZ+Vxlgd PgU9SnX/d6miuqXVgKqGGKNUzJLjBw== X-Received: by 10.28.107.210 with SMTP id a79mr5073647wmi.118.1498811680494; Fri, 30 Jun 2017 01:34:40 -0700 (PDT) MIME-Version: 1.0 Received: by 10.28.111.196 with HTTP; Fri, 30 Jun 2017 01:34:39 -0700 (PDT) In-Reply-To: References: <656ca1db-1082-b1ed-a911-ba7bf48f09c0@redhat.com> <20170629161506.GA25586@atrey.karlin.mff.cuni.cz> From: Richard Biener Date: Fri, 30 Jun 2017 10:34:39 +0200 Message-ID: Subject: Re: [PATCH] warn on mem calls modifying objects of non-trivial types (PR 80560) To: Martin Sebor Cc: Jan Hubicka , Jason Merrill , Pedro Alves , Gcc Patch List X-IsSubscribed: yes On Thu, Jun 29, 2017 at 10:23 PM, Martin Sebor wrote: > On 06/29/2017 10:15 AM, Jan Hubicka wrote: >> >> Hello, >>> >>> diff --git a/gcc/hash-table.h b/gcc/hash-table.h >>> index 0f7e21a..443d16c 100644 >>> --- a/gcc/hash-table.h >>> +++ b/gcc/hash-table.h >>> @@ -803,7 +803,10 @@ hash_table::empty_slow () >>> m_size_prime_index = nindex; >>> } >>> else >>> - memset (entries, 0, size * sizeof (value_type)); >>> + { >>> + for ( ; size; ++entries, --size) >>> + *entries = value_type (); >>> + } >>> m_n_deleted = 0; >>> m_n_elements = 0; >>> } >> >> >> This change sends our periodic testers into an infinite loop. It is fault >> of gcc 4.2 being used >> as bootstrap compiler, but perhaps that can be worked around? > > > The warning in the original code could have been suppressed (by > casting the pointer to char*), but it was valid so I opted not > to. I'd expect it to be possible to work around the bug but > I don't have easy access to GCC 4.2 to reproduce it or verify > the fix. > > FWIW, after looking at the function again, I wondered if zeroing > out the elements (either way) was the right thing to do and if > they shouldn't be cleared by calling Descriptor::mark_empty() > instead, like in alloc_entries(), but making that change broke > a bunch of ipa/ipa-pta-*.c tests. It's not really clear to me > what this code is supposed to do. > > Martin > > PS Does this help at all? > > @@ -804,8 +804,8 @@ hash_table::empty_slow () > } > else > { > - for ( ; size; ++entries, --size) > - *entries = value_type (); > + for (size_t i = 0; i != size; ++i) > + entries[i] = value_type (); > > } > m_n_deleted = 0; > m_n_elements = 0; alloc_entries uses mark_empty. untested: Index: gcc/hash-table.h =================================================================== --- gcc/hash-table.h (revision 249780) +++ gcc/hash-table.h (working copy) @@ -804,8 +804,8 @@ hash_table::empty } else { - for ( ; size; ++entries, --size) - *entries = value_type (); + for (size_t i = 0; i < size; ++i) + mark_empty (entries[i]); } m_n_deleted = 0; m_n_elements = 0;