From patchwork Tue Dec 27 04:39:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Oliva X-Patchwork-Id: 36775 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp1223154wrt; Mon, 26 Dec 2022 20:40:23 -0800 (PST) X-Google-Smtp-Source: AMrXdXsCoADPwMe/JKgB3kkySexnRc2cuAJkpklYbZk66186AbKYbw0k0TtrQFZvol4whMHH4mzE X-Received: by 2002:a17:907:7da4:b0:78d:f455:b5dc with SMTP id oz36-20020a1709077da400b0078df455b5dcmr19923293ejc.28.1672116023051; Mon, 26 Dec 2022 20:40:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672116023; cv=none; d=google.com; s=arc-20160816; b=bE6RCh7BhDunkmzP7XZvHJB/NXlPzloSIIbM5tk9gnAd4YiDVrKiSPIyXEAdlrr62S v67wyhlOrqOQmJAc7MwDKMVnJDPlLqV8D1SP55OudC/mFZv7q7Uq242xh83JowmGtbLP 8+4kVrIgAo8Aa4R16OjcdM++j7G/R0n/kSu8uYzLpdomZAfJMKHTyBZ41nrdjhZoQLmi jIwKH2/aLQx0HHrVdyT15paR9/XRV5lS51Bby94FBlc22HPL/SNZGkZ0nL11hvdPIkN8 Ovj/L0Hm6EZcTzRSW5Wi2fl+7GxRz2LEEOc/4iYMxM5TrWFk0VxA6M0JXQWcl8LXr3Vt b45A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:mime-version :user-agent:message-id:in-reply-to:date:references:organization :subject:to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=QfuLFqacFOLfzmRv/gdCEZF7xCNP+kn61CNo/gKr2WE=; b=eefRP0A4hXvPPjO6CZmkOsXi8O7WRvzGPRp1bIYE29IIST0w2SX+gx3gdAXNxzk22e QdVFZ8XvkY0dFgZwYiZzL1xaXLT0+fkw/U7LwZGge9j4PyTBjDApYnn3xudIsqEVplDZ zd0Xx+K/V/u5aa8gBbL0kf+w93FWoY6BjDmrN/NWnVwVDEPtaZ/7InXO7jph5yhASVpF 6/Nifnm8eBTw36APU4rr+R1xeLkxLA3VOEy8FlakUHsFpeb5g9ErOgODHNHUwBcbrjNc IKvUrCQJIAO9aljJdUfx8jG1Nuj9yJqxK4tnRs9d6d5MBbPADxXaVO+bzo2NO0rx6THc lzGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=HnFh48n1; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id fj3-20020a1709069c8300b0084b9ac8f8a3si6743384ejc.836.2022.12.26.20.40.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Dec 2022 20:40:23 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=HnFh48n1; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1FDFC3858410 for ; Tue, 27 Dec 2022 04:40:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1FDFC3858410 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1672116022; bh=QfuLFqacFOLfzmRv/gdCEZF7xCNP+kn61CNo/gKr2WE=; h=To:Subject:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=HnFh48n1ykpBFBt9OOdhm8qpi/l22OyG4TupnIdiJrMmCBsa+uWQzQQLLzmFR3YnT KFQLsJK3hM2GfOT7+skkCZzw6DYu8CeCrq2J2q7TpTXg+sqshHd0EqiOGUVIwfuGVo 0d6b28GquT0Po9xci/bJtxLBOZVvNhRYCXaUoPHo= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from rock.gnat.com (rock.gnat.com [205.232.38.15]) by sourceware.org (Postfix) with ESMTPS id 0B6933858C27 for ; Tue, 27 Dec 2022 04:39:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0B6933858C27 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id D31D61162A6; Mon, 26 Dec 2022 23:39:39 -0500 (EST) X-Virus-Scanned: Debian amavisd-new at gnat.com Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id lzd7Cq5YcRbW; Mon, 26 Dec 2022 23:39:39 -0500 (EST) Received: from free.home (tron.gnat.com [IPv6:2620:20:4000:0:46a8:42ff:fe0e:e294]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPS id 9B38711628F; Mon, 26 Dec 2022 23:39:39 -0500 (EST) Received: from livre (livre.home [172.31.160.2]) by free.home (8.15.2/8.15.2) with ESMTPS id 2BR4dUtv712633 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 27 Dec 2022 01:39:30 -0300 To: gcc-patches@gcc.gnu.org Subject: [13/13] hash-map: reject empty-looking insertions Organization: Free thinker, does not speak for AdaCore References: Date: Tue, 27 Dec 2022 01:39:30 -0300 In-Reply-To: (Alexandre Oliva's message of "Tue, 27 Dec 2022 01:07:35 -0300") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Alexandre Oliva via Gcc-patches From: Alexandre Oliva Reply-To: Alexandre Oliva Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1753340731232655215?= X-GMAIL-MSGID: =?utf-8?q?1753340731232655215?= Check, after inserting entries, that they don't look empty. Regstrapped on x86_64-linux-gnu. Ok to install? for gcc/ChangeLog * hash-map.h (put, get_or_insert): Check that entry does not look empty after insertion. --- gcc/hash-map.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gcc/hash-map.h b/gcc/hash-map.h index 457967f4bf1ae..63fa21cf37c5b 100644 --- a/gcc/hash-map.h +++ b/gcc/hash-map.h @@ -169,11 +169,12 @@ public: { hash_entry *e = m_table.find_slot_with_hash (k, Traits::hash (k), INSERT); - bool ins = hash_entry::is_empty (*e); + bool ins = Traits::is_empty (*e); if (ins) { e->m_key = k; new ((void *) &e->m_value) Value (v); + gcc_checking_assert (!Traits::is_empty (*e)); } else e->m_value = v; @@ -203,6 +204,7 @@ public: { e->m_key = k; new ((void *)&e->m_value) Value (); + gcc_checking_assert (!Traits::is_empty (*e)); } if (existed != NULL)