www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10955] New: std.getopt errors internally when insufficient arguments are passed

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10955

           Summary: std.getopt errors internally when insufficient
                    arguments are passed
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Optlink
        AssignedTo: nobody puremagic.com
        ReportedBy: andrej.mitrovich gmail.com



09:24:37 PDT ---
-----
import std.getopt;

void main(string[] args)
{
    int i;
    getopt(args, &i);
}
-----

std\getopt.d(392): Error: array index [1] is outside array bounds [0 .. 1]
std\getopt.d(401): Error: string slice [2 .. 1] is out of bounds
std\getopt.d(401): Error: cannot return non-void from void function
std\getopt.d(351): Error: template instance std.getopt.getoptImpl!(int*) error
instantiating

I think we can fix this easily:

before:
void getopt(T...)(ref string[] args, T opts) {

after:
void getopt(T...)(ref string[] args, T opts) if (T.length > 1) {

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 03 2013
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10955


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull
         AssignedTo|nobody puremagic.com        |andrej.mitrovich gmail.com



09:33:39 PDT ---
https://github.com/D-Programming-Language/phobos/pull/1542

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 03 2013