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

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Sep 3 09:24:39 PDT 2013


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 at puremagic.com
        ReportedBy: andrej.mitrovich at gmail.com


--- Comment #0 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2013-09-03 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: -------


More information about the Digitalmars-d-bugs mailing list