https://gcc.gnu.org/g:15c74ac9fdc69646f83238cac70d1bae36cb377e
commit r17-1310-g15c74ac9fdc69646f83238cac70d1bae36cb377e Author: Viljar Indus <[email protected]> Date: Thu May 14 15:05:21 2026 +0300 ada: Guard agains empty switches in GNAT.Command_Line.Getopt Checks for the first character in Switches being an '*' did not include guards against an empty string in all locations. gcc/ada/ChangeLog: * libgnat/g-comlin.adb (Getopt): Check if Switches are empty before looking at the first element. Diff: --- gcc/ada/libgnat/g-comlin.adb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gcc/ada/libgnat/g-comlin.adb b/gcc/ada/libgnat/g-comlin.adb index 18905cc135e6..ad7835733ca3 100644 --- a/gcc/ada/libgnat/g-comlin.adb +++ b/gcc/ada/libgnat/g-comlin.adb @@ -666,7 +666,7 @@ package body GNAT.Command_Line is -- isn't the parameter to a previous switch, since that has -- already been handled. - if Switches (Switches'First) = '*' then + if Switches /= "" and then Switches (Switches'First) = '*' then Set_Parameter (Parser.The_Switch, Arg_Num => Parser.Current_Argument, @@ -901,7 +901,8 @@ package body GNAT.Command_Line is -- If Concatenate is False and the full argument is not -- recognized as a switch, this is an invalid switch. - if Switches (Switches'First) = '*' then + if Switches /= "" and then Switches (Switches'First) = '*' + then Set_Parameter (Parser.The_Switch, Arg_Num => Parser.Current_Argument,
