I have been able to fix this problem by patching gnatlink.adb; patch attached.
I am puzzled by your report that this bug is not triggered in the home-built upstream gnat-4.9 snapshot (gcc-4.9-20140112). Could you please try the following in the directory containing mai_read_config.adb: cat > gdb-gnatlink <<EOF #!/bin/sh exec gdb ..../gnatlink # here, substitute the absolute path to gnatlink EOF gnatmake -D obj --GNATLINK=./gdb-gnatlink mai_read_config.adb The output should be: gnatbind -aO/home/lbrenta/src/ada/g/obj -x /home/lbrenta/src/ada/g/obj/mai_read_config.ali ./gdb-gnatlink /home/lbrenta/src/ada/g/obj/mai_read_config.ali (gdb) at which point you are in the debugger. In gdb: break base_name run obj/mai_read_config.ali finish print Linker_Options.Table (2).all'First If this is 1 without my patch then I am baffled; if this is 5 (the index of the letter 'm' in the string "obj/mai_read_config.ali") then you should later see the same bug as in the Debian build of gnatlink. -- Ludovic Brenta.
From: Ludovic Brenta <lbre...@debian.org> Forwarded: no Bug-Debian: http://bugs.debian.org/749574 Description: Constraint_Error, range check failed at gnatlink.adb:2195, when called from gnatmake with -D option The procedure gnatlink assumes that the Linker_Options.Table contains access values to strings whose 'First index is always 1. This assumption is wrong for the string returned by function Base_Name. . Instead of fixing the assumption in many places, this patch changes the function Base_Name always to return a string with 'First=1. . This looks like an upstream bug but strangely the reporter of this bug says it does not happen on GCC built from upstream sources. Further investigation is required to determine whether or not to forward this bug and patch upstream. Index: b/src/gcc/ada/gnatlink.adb =================================================================== --- a/src/gcc/ada/gnatlink.adb +++ b/src/gcc/ada/gnatlink.adb @@ -273,7 +273,12 @@ Findex2 := File_Name'Last + 1; end if; - return File_Name (Findex1 .. Findex2 - 1); + declare + Result : String (1 .. Findex2 - Findex1); + begin + Result (1 .. Findex2 - Findex1) := File_Name (Findex1 .. Findex2 - 1); + return Result; + end; end Base_Name; -------------------------------