https://gcc.gnu.org/g:eb822805b51a1fa5b514a04a6e66556e3dcd3484
commit r15-1142-geb822805b51a1fa5b514a04a6e66556e3dcd3484 Author: Ronan Desplanques <desplanq...@adacore.com> Date: Fri Apr 12 16:45:08 2024 +0200 ada: Fix incorrect lower bound presumption in gnatlink This patch fixes a subprogram in gnatlink that incorrectly assumed that the strings it is passed as arguments all have a lower bound of 1. gcc/ada/ * gnatlink.adb (Check_File_Name): Fix incorrect assumption. Diff: --- gcc/ada/gnatlink.adb | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/gcc/ada/gnatlink.adb b/gcc/ada/gnatlink.adb index d00fd9e5af7..1455412ef93 100644 --- a/gcc/ada/gnatlink.adb +++ b/gcc/ada/gnatlink.adb @@ -42,6 +42,7 @@ with Types; with Ada.Command_Line; use Ada.Command_Line; with Ada.Exceptions; use Ada.Exceptions; +with Ada.Strings.Fixed; with System.OS_Lib; use System.OS_Lib; with System.CRTL; @@ -1697,15 +1698,13 @@ begin procedure Check_File_Name (S : String) is begin - for J in 1 .. FN'Length - (S'Length - 1) loop - if FN (J .. J + (S'Length - 1)) = S then - Error_Msg - ("warning: executable file name """ & Output_File_Name.all - & """ contains substring """ & S & '"'); - Error_Msg - ("admin privileges may be required to run this file"); - end if; - end loop; + if Ada.Strings.Fixed.Index (FN, S) /= 0 then + Error_Msg + ("warning: executable file name """ & Output_File_Name.all + & """ contains substring """ & S & '"'); + Error_Msg + ("admin privileges may be required to run this file"); + end if; end Check_File_Name; -- Start of processing for Bad_File_Names_On_Windows