{"id":2222663,"url":"http://patchwork.ozlabs.org/api/1.2/patches/2222663/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/patch/4727119.LvFx2qVVIh@fomalhaut/","project":{"id":17,"url":"http://patchwork.ozlabs.org/api/1.2/projects/17/?format=json","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":"<4727119.LvFx2qVVIh@fomalhaut>","list_archive_url":null,"date":"2026-04-13T10:46:09","name":"[Ada] Fix invalid memory accesses in GNAT.Perfect_Hash_Generators with non-1-based strings","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"79c8570684045d7b20f9b2419f63a173a6994e42","submitter":{"id":78832,"url":"http://patchwork.ozlabs.org/api/1.2/people/78832/?format=json","name":"Eric Botcazou","email":"botcazou@adacore.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/gcc/patch/4727119.LvFx2qVVIh@fomalhaut/mbox/","series":[{"id":499681,"url":"http://patchwork.ozlabs.org/api/1.2/series/499681/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/list/?series=499681","date":"2026-04-13T10:46:09","name":"[Ada] Fix invalid memory accesses in GNAT.Perfect_Hash_Generators with non-1-based strings","version":1,"mbox":"http://patchwork.ozlabs.org/series/499681/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2222663/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2222663/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=lX3Abz4/;\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=lX3Abz4/","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.48"],"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 4fvPTt2T5Lz1y2d\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 13 Apr 2026 20:56:18 +1000 (AEST)","from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 831564BA2E2D\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 13 Apr 2026 10:56:16 +0000 (GMT)","from mail-wm1-f48.google.com (mail-wm1-f48.google.com\n [209.85.128.48])\n by sourceware.org (Postfix) with ESMTPS id A72684BA2E0F\n for <gcc-patches@gcc.gnu.org>; Mon, 13 Apr 2026 10:54:26 +0000 (GMT)","by mail-wm1-f48.google.com with SMTP id\n 5b1f17b1804b1-488b8efed61so40297535e9.1\n for <gcc-patches@gcc.gnu.org>; Mon, 13 Apr 2026 03:54:26 -0700 (PDT)","from fomalhaut.localnet ([2a01:e0a:107c:2f10:e654:e8ff:fe8f:2ce6])\n by smtp.gmail.com with ESMTPSA id\n 5b1f17b1804b1-488d53808b2sm354291335e9.11.2026.04.13.03.54.24\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:25 -0700 (PDT)"],"DKIM-Filter":["OpenDKIM Filter v2.11.0 sourceware.org 831564BA2E2D","OpenDKIM Filter v2.11.0 sourceware.org A72684BA2E0F"],"DMARC-Filter":"OpenDMARC Filter v1.4.2 sourceware.org A72684BA2E0F","ARC-Filter":"OpenARC Filter v1.0.0 sourceware.org A72684BA2E0F","ARC-Seal":"i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776077666; cv=none;\n b=vAH7QhlbgWRqvPwQYxrEsb6hhL+rDIb8vwGumIqwrLu6ijmYwvlbeJ4hMMjgTgv2UDwODfYAA4PJiN4Qw1Af6zoWT4z7gg+FfqEYu3L62PKp0ioiLgPpFb/NdEab528oS5/Rzbf1XLbi4zB4jcCh7d7i67MK+epMVMyr8UCkTJU=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1776077666; c=relaxed/simple;\n bh=8MEJEES9HvxhA4tdLRUruc6YdJS3v5rbLaj8vX+ML0I=;\n h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version;\n b=NkdbSrtzzrzTP2jJaRxoANBoUl5iQbw8gSsAdYqIcwCVWk40nQMfuWGE/gCWimrdSnU7d1PUPMqHtwvrrKUEFwRh2HJkuZyRxVxUGwolCu4Wydbp3n9+uz56OqQ7o1bsvt1RoitX73Fg2tfwtHL7WmUZ035rTnW2PxF/w34koFQ=","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=1776077665; x=1776682465; 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=k8UkkADeseq47YUxZT7jij+ewpoxrSuQUwPVCC10J+g=;\n b=lX3Abz4/TloqLNWc6WBH+slx6T40zL1RE2vlU56x0oFfz6Fw2B+w7G82yeHQRsUDx7\n aG6LUV706nRxxsOtTgKvZAwLiReowMrM0myqX/oKTEo2LyZqvfgphS3F+16LiqIraKPB\n fXmpuMScT/2CSq5dw5+dLQh0aYWCqaFeBMgE2pqiIIpzQiSvY8BBo2uSbkP57C6Rccnf\n qo6td5YquvnjZ5UREq0KZux1HVdy1wJQOZRSUvkvYVNGR+AivVlqUkNV1ww5vm1npvOF\n BoGcJlhx50OkIXojJDhdPHW7IBlIqf17yK3IdjfZhb+qlq8rGzWuGDg418vz+A4Wrub2\n w+6Q==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1776077665; x=1776682465;\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=k8UkkADeseq47YUxZT7jij+ewpoxrSuQUwPVCC10J+g=;\n b=j6y+sEtFZlOu8TqvN/YO9FsgrmdLAlV3qohCncpiUukagQCK3tqrE5IN4Toy1ojOUq\n GML6X8CPlqZsQLfu9cgqDV6trC1knyetuY3mB20rrAyvtS+sW36e6alO8+04QBs95R3e\n gAzt0v5fqVa8s9be63zka2hvGJgu6OQrybbjjnmqeyzeOb1RVQy04XFqUlQmNhEFylM3\n dYAKduGYCuvspBss67vNcy0gw9M6nAADI4hDqdDxrBK1c7/qFuuxuYxtfaspgByP30sx\n MvQU/NfjZn9F+vtYipNPaxnS3Ym/qlnS8SgFOBgCx/OqjdyAa8KJCSTWGn85qn7G8/4V\n fsYQ==","X-Gm-Message-State":"AOJu0YxhkjO4dvDGiqYZ/6wN7m1TlB9wD5xz9ZtzuHzhUQng35i5uuvP\n j9Q8DMQqiCQeRJxQ7nNvTKF5+DOxpR1rpuG5JgsvNc89AThDtb7LoCPlEUrYTr9t4oKnyKsVFWb\n iar8=","X-Gm-Gg":"AeBDievMwlPhnCEjE2UNnOhysU7rCA0dZZJJRax3vZhFglEvc8sM4XGpkoH7lgQZUBR\n 1YrIPLGI/YwWxtDF37Ul+epS0ybwOJIAqPmM2Xq4YexTiqaRzWByUrOoIy4nnLcSD2B/hBLVjAz\n ZAt4FDnrO53FCBcmjDwwT4nhVlkdFi49qx+wNIVkDb7kcpEf31u6r1tb3OmP83CTMhpBGkWYrKh\n zxdYCtyB6x3PkZfnrs6u6c+L6tVMNXe0YUb3Ke2zV13AwreQpvCNAoaeBgApIAwCgqt0guTlE6q\n 8q+PUJvKH4OqOF0vhsL49qCbKOCKoa8DKJYDc6WPLqbjzJ95gNM0SSbL8uOcxqCNcz+Fc3XKtSt\n 0E7AhpP2GaEnRn8V3UrDqJrQkbxAriRK59/eqBJqL8GRk9xxM7VBQfiq3yyHkft0egslPhD0P3i\n qoOWb5KfHN1bTc9w+wPLhdjYTntU9QZOLZt5F1","X-Received":"by 2002:a05:600c:a406:b0:488:aa33:dc8f with SMTP id\n 5b1f17b1804b1-488d6781cf5mr135158475e9.0.1776077665499;\n Mon, 13 Apr 2026 03:54:25 -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 invalid memory accesses in GNAT.Perfect_Hash_Generators\n with\n non-1-based strings","Date":"Mon, 13 Apr 2026 12:46:09 +0200","Message-ID":"<4727119.LvFx2qVVIh@fomalhaut>","MIME-Version":"1.0","Content-Type":"multipart/mixed; boundary=\"nextPart2406862.ElGaqSPkdT\"","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/77535\n\t* libgnat/s-pehage.adb (New_Word): Rebase the input.","diff":"diff --git a/gcc/ada/libgnat/s-pehage.adb b/gcc/ada/libgnat/s-pehage.adb\nindex e80fa00cd33..dcc5e6742fc 100644\n--- a/gcc/ada/libgnat/s-pehage.adb\n+++ b/gcc/ada/libgnat/s-pehage.adb\n@@ -1275,8 +1275,9 @@ package body System.Perfect_Hash_Generators is\n    --------------\n \n    function New_Word (S : String) return Word_Type is\n+      subtype Word_String is String (1 .. S'Length);\n    begin\n-      return new String'(S);\n+      return new String'(Word_String (S));\n    end New_Word;\n \n    ------------------------------\n","prefixes":["Ada"]}