From patchwork Fri Jun 16 14:52:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 776789 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 3wq3Hn4yGNz9s3s for ; Sat, 17 Jun 2017 00:52:19 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="v6fQ6d2f"; 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:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=Ny4o4pyK6dY62enMSfn6+Lc+ShZGtM8z4QdLdmUPMjlLrUjejD OCfOStqnSRl7fQgiwaJCBWJP47y1fS4bYahXpkGfH/MtqclrHGIfba/vqg8D5/yH UIG1e8gF6v6e3/adK4qm4Q8mIUHnvk5S4hogLXwp+HgXTzHxPXVa8JiZI= 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:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=s5VYbIDo8vNOrBcjWPNTdUuzo9c=; b=v6fQ6d2f8mtdSHDn7qr2 Pzz2+f4ftB3CD27A55P/DJcIA//C3Cdeyu4TdgA0Sc/KstG96sC9CPsh3mZTBwFV 4NH+qVeS4fn0kEaIFkC4zmwuaKzT29yyeLHcyCM3p0SPCQDYAbLOSU+avJcKdOd5 KnlrNPaseSFPb5Mvffi4qc8= Received: (qmail 82576 invoked by alias); 16 Jun 2017 14:52:02 -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 82563 invoked by uid 89); 16 Jun 2017 14:52:01 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=suffered, story X-HELO: mail-yb0-f170.google.com Received: from mail-yb0-f170.google.com (HELO mail-yb0-f170.google.com) (209.85.213.170) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 16 Jun 2017 14:52:00 +0000 Received: by mail-yb0-f170.google.com with SMTP id f192so13131210yba.2 for ; Fri, 16 Jun 2017 07:52:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:to:from:subject:message-id:date :user-agent:mime-version:content-language; bh=XDOfC3ckWXU2OwijCIBOZ9LNxzSOBKkVZzgGGbld7uo=; b=JvDWuqDIxxnoiXIW8m5ZFQAUyVkYveljafFL4jYStH/zvOUBofJVAFBCxh/fxDPZV1 HEyhTgReyHhco12wqHkY0gTMhO3fyWfh7z9bgiHTtiFoAhVZeIeMcJT2Y9Wvu9Ulcq03 XXQTa/aAqbUbM7fhb++mc/Bm6uS2h/KToiEpy76zL/34tGCMvK7DcX5yoP7Xsiau5FCX W4om1gZQ+k4AyqbMZ0pbjtCI40bwum3PXDY8B9aBfmhyh6ihHZGlUyZZyUIpg3jR5flk 5mIWafypW53ZUk5OyfUjo2nsc+UkPHv2aHKe+C/GZyxI1lNkp0nvskK9Cl869uMhKeUw AZ7A== X-Gm-Message-State: AKS2vOwmQkA8k//56irs/QmOUV7Kg+S0RL3nUoaGoM3M38by1Ch9CsON hCC5e7uPGCAm2w== X-Received: by 10.37.161.170 with SMTP id a39mr9617233ybi.168.1497624723502; Fri, 16 Jun 2017 07:52:03 -0700 (PDT) Received: from ?IPv6:2620:10d:c0a3:20fb:7500:e7fb:4a6f:2254? ([2620:10d:c091:200::144]) by smtp.googlemail.com with ESMTPSA id s5sm974989ywd.26.2017.06.16.07.52.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Jun 2017 07:52:03 -0700 (PDT) To: GCC Patches From: Nathan Sidwell Subject: [C++ PATCH] class method vector Message-ID: Date: Fri, 16 Jun 2017 10:52:01 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.0 MIME-Version: 1.0 The class method vector needs resorting on PCH readin, and module readback. It suffered an unfortunate signed/unsigned comparison collision, that I hit. Reworked to be made safer. Of course this thing should really be a hash table + vector of type conversions, but that's another story. applied to trunk. nathan 2017-06-16 Nathan Sidwell * class.c (resort_type_method_vec): Avoid potential unsigned overflow. Index: class.c =================================================================== --- class.c (revision 249264) +++ class.c (working copy) @@ -2328,25 +2328,25 @@ resort_type_method_vec (void* obj, gt_pointer_operator new_value, void* cookie) { - vec *method_vec = (vec *) obj; - int len = vec_safe_length (method_vec); - size_t slot; - tree fn; + if (vec *method_vec = (vec *) obj) + { + int len = method_vec->length (); + int slot; - /* The type conversion ops have to live at the front of the vec, so we - can't sort them. */ - for (slot = CLASSTYPE_FIRST_CONVERSION_SLOT; - vec_safe_iterate (method_vec, slot, &fn); - ++slot) - if (!DECL_CONV_FN_P (OVL_FIRST (fn))) - break; + /* The type conversion ops have to live at the front of the vec, so we + can't sort them. */ + for (slot = CLASSTYPE_FIRST_CONVERSION_SLOT; + slot < len; slot++) + if (!DECL_CONV_FN_P (OVL_FIRST ((*method_vec)[slot]))) + break; - if (len - slot > 1) - { - resort_data.new_value = new_value; - resort_data.cookie = cookie; - qsort (method_vec->address () + slot, len - slot, sizeof (tree), - resort_method_name_cmp); + if (len > slot + 1) + { + resort_data.new_value = new_value; + resort_data.cookie = cookie; + qsort (method_vec->address () + slot, len - slot, sizeof (tree), + resort_method_name_cmp); + } } }