Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/1.2/patches/2222662/?format=api
{ "id": 2222662, "url": "http://patchwork.ozlabs.org/api/1.2/patches/2222662/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/patch/13988372.uLZWGnKmhe@fomalhaut/", "project": { "id": 17, "url": "http://patchwork.ozlabs.org/api/1.2/projects/17/?format=api", "name": "GNU Compiler Collection", "link_name": "gcc", "list_id": "gcc-patches.gcc.gnu.org", "list_email": "gcc-patches@gcc.gnu.org", "web_url": null, "scm_url": null, "webscm_url": null, "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<13988372.uLZWGnKmhe@fomalhaut>", "list_archive_url": null, "date": "2026-04-13T10:51:58", "name": "[Ada] Fix spurious overflow in the Heapsort implementations", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "03dce724f9ecd59bbd210bef8b7837673995eaa1", "submitter": { "id": 78832, "url": "http://patchwork.ozlabs.org/api/1.2/people/78832/?format=api", "name": "Eric Botcazou", "email": "botcazou@adacore.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/gcc/patch/13988372.uLZWGnKmhe@fomalhaut/mbox/", "series": [ { "id": 499680, "url": "http://patchwork.ozlabs.org/api/1.2/series/499680/?format=api", "web_url": "http://patchwork.ozlabs.org/project/gcc/list/?series=499680", "date": "2026-04-13T10:51:58", "name": "[Ada] Fix spurious overflow in the Heapsort implementations", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/499680/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2222662/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2222662/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org>", "X-Original-To": [ "incoming@patchwork.ozlabs.org", "gcc-patches@gcc.gnu.org" ], "Delivered-To": [ "patchwork-incoming@legolas.ozlabs.org", "gcc-patches@gcc.gnu.org" ], "Authentication-Results": [ "legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256\n header.s=google header.b=OqaHCLg2;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org\n (client-ip=2620:52:6:3111::32; helo=vm01.sourceware.org;\n envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org;\n receiver=patchwork.ozlabs.org)", "sourceware.org;\n\tdkim=pass (2048-bit key,\n secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256\n header.s=google header.b=OqaHCLg2", "sourceware.org; dmarc=pass (p=quarantine dis=none)\n header.from=adacore.com", "sourceware.org; spf=pass smtp.mailfrom=adacore.com", "server2.sourceware.org;\n arc=none smtp.remote-ip=209.85.128.45" ], "Received": [ "from vm01.sourceware.org (vm01.sourceware.org\n [IPv6:2620:52:6:3111::32])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fvPSK4RnHz1yDF\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 13 Apr 2026 20:54:56 +1000 (AEST)", "from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 427434BA2E15\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 13 Apr 2026 10:54:54 +0000 (GMT)", "from mail-wm1-f45.google.com (mail-wm1-f45.google.com\n [209.85.128.45])\n by sourceware.org (Postfix) with ESMTPS id 665684BA2E0D\n for <gcc-patches@gcc.gnu.org>; Mon, 13 Apr 2026 10:54:25 +0000 (GMT)", "by mail-wm1-f45.google.com with SMTP id\n 5b1f17b1804b1-4887ca8e529so27496455e9.0\n for <gcc-patches@gcc.gnu.org>; Mon, 13 Apr 2026 03:54:25 -0700 (PDT)", "from fomalhaut.localnet ([2a01:e0a:107c:2f10:e654:e8ff:fe8f:2ce6])\n by smtp.gmail.com with ESMTPSA id\n 5b1f17b1804b1-488d538c03esm289740165e9.13.2026.04.13.03.54.23\n for <gcc-patches@gcc.gnu.org>\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Mon, 13 Apr 2026 03:54:23 -0700 (PDT)" ], "DKIM-Filter": [ "OpenDKIM Filter v2.11.0 sourceware.org 427434BA2E15", "OpenDKIM Filter v2.11.0 sourceware.org 665684BA2E0D" ], "DMARC-Filter": "OpenDMARC Filter v1.4.2 sourceware.org 665684BA2E0D", "ARC-Filter": "OpenARC Filter v1.0.0 sourceware.org 665684BA2E0D", "ARC-Seal": "i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776077665; cv=none;\n b=b22/9ZmS+uM/4CpHIo4pJ+E8DA+rhVRKKdDEVMz+cEBprnbip4D2GWsXLhaC1Uwp8R2z1DZiQ6m1CrD69fxtrvkW6O6M3ZYsUION/51bxn9T7mOrsVmHZeV02bwphqv5tICJLjtdtpx85TPsrsPiXP28ix41H6HKlrY/PHhyF0s=", "ARC-Message-Signature": "i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1776077665; c=relaxed/simple;\n bh=3swLMM9LTP1t0VKTr2OcNYpW0CPfUxehCBHXIkjW3nk=;\n h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version;\n b=XPIooVpZ8r74thaZSTfD3l8PAU8xRBRCIJv/s+pa4hkfccEPpQ1UUYrJLIrl1Z6tvOOD3X4IbTzAXevl6b0tiKLs9ENq/JU8HAKreQAV6Epr+UUp4sa88JK9sh096vOmvQm8KNMQ7+PJU3DHG7VlhWU4C1OAaoYujWqu4gLLve8=", "ARC-Authentication-Results": "i=1; server2.sourceware.org", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=adacore.com; s=google; t=1776077664; x=1776682464; darn=gcc.gnu.org;\n h=content-transfer-encoding:mime-version:message-id:date:subject:to\n :from:from:to:cc:subject:date:message-id:reply-to;\n bh=K4zjpTwbxjJeBEM4WYIeSXDlrUJpRHRDc4EDfViDgwo=;\n b=OqaHCLg2EVssQLs6cv0L2R3ViXHd5aOkvvFuhqSj5FindhvCBh4q/TPZf0LfCI/NNw\n 6nLktRlag0VxQx5OdB+7KtTsXfj2cAodS2/6dYrk8lsAwS9tge3iAyWva3ZO8B1scEuv\n V93mRFNJjn6cgN7iljoGANNO8xEH92kZM3tAr2yYjNf6gam4QZwMS4Li3+g200XdIV+S\n ol9uHiGc7m3xlfmyea0z4mcx4EY38JdcJLaSCRFMl3OfoiJnP4ZXJ+E+pS6E/IWt9rAV\n cMr+xoNHFKyqVO/Rp7LDnF+t8s/7UqSnQitA7hGoZYmLMVnsuPmOx167nN31Pki87ckN\n YPqw==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1776077664; x=1776682464;\n h=content-transfer-encoding:mime-version:message-id:date:subject:to\n :from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id\n :reply-to;\n bh=K4zjpTwbxjJeBEM4WYIeSXDlrUJpRHRDc4EDfViDgwo=;\n b=kfSgExjtqQMpleysp1JLe2cwqyqWjFbY/RhXAu7+iiza4PQM0op8hQAjUjGNk/ePZA\n +VuIaZJJz+GRa1IuUYB+kQY+JEn/2I6+TEq6iHQ3Ji9AJdYfUlDGR5eCzlJQfL30NVc9\n 7I5Cwjx7SLovngalvxK2qOrT3UQtW3yZKyE7SvpsqpA3h2jxci8pg1LI69TxlO66rz92\n bL608HMHE6PXveQIKCicnx4PuT2vAO+sSQay4oYKEJ6Rz6gfhMzajvIBbT8JbBeHAUDX\n 9nn8A8gAQe+JQWmTJSU43n4JRnzInADt2U6bYaOUasSgpfH2/WeC4ahNu3r1orHPzvgF\n PRIg==", "X-Gm-Message-State": "AOJu0YxXuuY/NYfMj0bbpdK7oGMCEKFnbmhuC+3K0Y+d//DeECOlkJtI\n T2sg2qHAsNCdk8zx7rBvYlh/DAA4O1zYzVxRThbLqRcgk7qU+y3cHaLC36sRSwlzppUy+t8vo53\n u9Gk=", "X-Gm-Gg": "AeBDievc1N50BsII8L8gAAorfIgbDpWWBJ6IxB2eolhfYMsR76Qm2ORQXRQncpJ0ebo\n hOBROUzIGjI4WAKS8m91nE9CGGiBlnamKWHTu0jAdvIvr+OX/9H67RL0I+z6vLajNaPCIgpReW4\n UMhbF9ro1hynkxFFwk/972PFYMUZMz27KzK/LNV4bMltrtieSie2N8XGJ+pXdIqaNv+bMAkEynt\n ARjkzTXs3tQ8IB/YD3rXNZ9CBm8YipB683eH7aOTEV0C3RD5Eoj6LRTwWmHS7+5VR4Qc4WzEKrf\n aJCRTYm+qk5SkuEXsL8CXEEZTXzmcsZ5N8SdgtInFpaXuYUEKjRFxI709l/3sgmsIUR3PpPDr0p\n yuZ6GtcfiOnfYNbIId7kHl36488LWbgxzCjLtr32kWIp3ccHbljhlXWrVEWctOQ+xhkXW1g2SFx\n lfaOej32buohwdTtHlaRCXhvUwkDzD3GAfqEei", "X-Received": "by 2002:a05:600c:c08b:b0:485:3c2e:60d5 with SMTP id\n 5b1f17b1804b1-488d6816f66mr122034725e9.2.1776077664214;\n Mon, 13 Apr 2026 03:54:24 -0700 (PDT)", "From": "Eric Botcazou <botcazou@adacore.com>", "X-Google-Original-From": "Eric Botcazou <ebotcazou@adacore.com>", "To": "gcc-patches@gcc.gnu.org", "Subject": "[Ada] Fix spurious overflow in the Heapsort implementations", "Date": "Mon, 13 Apr 2026 12:51:58 +0200", "Message-ID": "<13988372.uLZWGnKmhe@fomalhaut>", "MIME-Version": "1.0", "Content-Type": "multipart/mixed; boundary=\"nextPart3039539.e9J7NaK4W3\"", "Content-Transfer-Encoding": "7Bit", "X-BeenThere": "gcc-patches@gcc.gnu.org", "X-Mailman-Version": "2.1.30", "Precedence": "list", "List-Id": "Gcc-patches mailing list <gcc-patches.gcc.gnu.org>", "List-Unsubscribe": "<https://gcc.gnu.org/mailman/options/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe>", "List-Archive": "<https://gcc.gnu.org/pipermail/gcc-patches/>", "List-Post": "<mailto:gcc-patches@gcc.gnu.org>", "List-Help": "<mailto:gcc-patches-request@gcc.gnu.org?subject=help>", "List-Subscribe": "<https://gcc.gnu.org/mailman/listinfo/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe>", "Errors-To": "gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org" }, "content": "That's an ancient issue, but the fix is trivial.\n\nTested on x86-64/Linux, applied on the mainline.\n\n\n2026-04-13 Eric Botcazou <ebotcazou@adacore.com>\n\n\tPR ada/95452\n\t* libgnat/g-heasor.adb (Sort.Sift): Add guard against overflow.\n\t* libgnat/g-hesorg.adb (Sort.Sift): Likewise.\n\t* libgnat/g-hesora.adb (Sort.Sift): Likewise. Restore consistency.", "diff": "diff --git a/gcc/ada/libgnat/g-heasor.adb b/gcc/ada/libgnat/g-heasor.adb\nindex dbdaa1ce920..03a490c4634 100644\n--- a/gcc/ada/libgnat/g-heasor.adb\n+++ b/gcc/ada/libgnat/g-heasor.adb\n@@ -45,10 +45,9 @@ package body GNAT.Heap_Sort is\n -- from 2NlogN to NlogN.\n \n procedure Sort (N : Natural; Xchg : Xchg_Procedure; Lt : Lt_Function) is\n+\n Max : Natural := N;\n- -- Current Max index in tree being sifted. Note that we make Max\n- -- Natural rather than Positive so that the case of sorting zero\n- -- elements is correctly handled (i.e. does nothing at all).\n+ -- Current Max index in tree being sifted\n \n procedure Sift (S : Positive);\n -- This procedure sifts up node S, i.e. converts the subtree rooted\n@@ -78,7 +77,9 @@ package body GNAT.Heap_Sort is\n -- Loop to pull up larger sons\n \n loop\n- Son := C + C;\n+ exit when C > Positive'Last / 2;\n+\n+ Son := 2 * C;\n \n if Son < Max then\n if Lt (Son, Son + 1) then\ndiff --git a/gcc/ada/libgnat/g-hesora.adb b/gcc/ada/libgnat/g-hesora.adb\nindex 99aab321fa7..dad04e579eb 100644\n--- a/gcc/ada/libgnat/g-hesora.adb\n+++ b/gcc/ada/libgnat/g-hesora.adb\n@@ -57,6 +57,10 @@ package body GNAT.Heap_Sort_A is\n -- entry are irrelevant. This is just a minor optimization to avoid\n -- what would otherwise be two junk moves in phase two of the sort.\n \n+ ----------\n+ -- Sift --\n+ ----------\n+\n procedure Sift (S : Positive) is\n C : Positive := S;\n Son : Positive;\n@@ -76,11 +80,16 @@ package body GNAT.Heap_Sort_A is\n -- Loop to pull up larger sons\n \n loop\n+ exit when C > Positive'Last / 2;\n+\n Son := 2 * C;\n- exit when Son > Max;\n \n- if Son < Max and then Lt (Son, Son + 1) then\n- Son := Son + 1;\n+ if Son < Max then\n+ if Lt (Son, Son + 1) then\n+ Son := Son + 1;\n+ end if;\n+ elsif Son > Max then\n+ exit;\n end if;\n \n Move (Son, C);\n@@ -126,7 +135,6 @@ package body GNAT.Heap_Sort_A is\n Max := Max - 1;\n Sift (1);\n end loop;\n-\n end Sort;\n \n end GNAT.Heap_Sort_A;\ndiff --git a/gcc/ada/libgnat/g-hesorg.adb b/gcc/ada/libgnat/g-hesorg.adb\nindex cf8ec2072b2..26447125ff4 100644\n--- a/gcc/ada/libgnat/g-hesorg.adb\n+++ b/gcc/ada/libgnat/g-hesorg.adb\n@@ -67,9 +67,6 @@ package body GNAT.Heap_Sort_G is\n C : Positive := S;\n Son : Positive;\n Father : Positive;\n- -- Note: by making the above all Positive, we ensure that a test\n- -- against zero for the temporary location can be resolved on the\n- -- basis of types when the routines are inlined.\n \n begin\n -- This is where the optimization is done, normally we would do a\n@@ -85,6 +82,8 @@ package body GNAT.Heap_Sort_G is\n -- Loop to pull up larger sons\n \n loop\n+ exit when C > Positive'Last / 2;\n+\n Son := 2 * C;\n \n if Son < Max then\n@@ -138,7 +137,6 @@ package body GNAT.Heap_Sort_G is\n Max := Max - 1;\n Sift (1);\n end loop;\n-\n end Sort;\n \n end GNAT.Heap_Sort_G;\n", "prefixes": [ "Ada" ] }