[Bug ada/71358] New: GNAT.Command_Line.Getopt fails if there are no switches

simon at pushface dot org gcc-bugzilla@gcc.gnu.org
Tue May 31 15:35:00 GMT 2016


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71358

            Bug ID: 71358
           Summary: GNAT.Command_Line.Getopt fails if there are no
                    switches
           Product: gcc
           Version: 6.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: ada
          Assignee: unassigned at gcc dot gnu.org
          Reporter: simon at pushface dot org
  Target Milestone: ---

Created attachment 38611
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=38611&action=edit
Demonstrators

A program had no switches (yet), and calling Getopt resulted in CE. Having
patched this, calling the program with -h or --help resulted in a different
crash.

A GDB session for the first (no switches) case gave

Catchpoint 1, CONSTRAINT_ERROR at 0x0000000100001c1f in _ada_aes ()
    at /Users/simon/Analytical_Engine/src/aes.adb:53
53         GNAT.Command_Line.Getopt (Command_Line_Config);
(gdb) bt
[...]
#5  0x000000010009cad3 in __gnat_rcheck_CE_Access_Check (file=<optimized out>, 
    line=<optimized out>) at a-except.adb:1202
#6  0x0000000100047c94 in gnat__command_line__getopt__2 (callback=0x0,
parser=0x101002000, 
    concatenate=true) at /Users/simon/Analytical_Engine/src/g-comlin.adb:3457
#7  0x0000000100001c1f in _ada_aes () at
/Users/simon/Analytical_Engine/src/aes.adb:53
(gdb) fr 6
#6  0x0000000100047c94 in gnat__command_line__getopt__2 (callback=0x0,
parser=0x101002000, 
    concatenate=true) at /Users/simon/Analytical_Engine/src/g-comlin.adb:3457
3457          for S in Config.Switches'Range loop
(gdb) fr 6
#6  0x0000000100047c94 in gnat__command_line__getopt__2 (callback=0x0,
parser=0x101002000, 
    concatenate=true) at /Users/simon/Analytical_Engine/src/g-comlin.adb:3457
3457          for S in Config.Switches'Range loop
(gdb) p config
$1 = (access gnat.command_line.command_line_configuration_record) 0x100700000
(gdb) p config.all
$2 = (prefixes => 0x0, sections => 0x1003000a8, star_switch => false, aliases
=> 0x0, 
  usage => 0x1003029a8, help => 0x1003029c8, help_msg => 0x1003014a8, switches
=> 0x0)

I have a demonstrator and a patch.


More information about the Gcc-bugs mailing list