Bug 10955 – std.getopt errors internally when insufficient arguments are passed

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-09-03T09:24:37Z
Last change time
2020-03-21T03:56:42Z
Keywords
pull
Assigned to
No Owner
Creator
Andrej Mitrovic

Comments

Comment #0 by andrej.mitrovich — 2013-09-03T09:24:37Z
----- 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) {
Comment #1 by andrej.mitrovich — 2013-09-03T09:33:39Z
Comment #2 by b2.temp — 2016-02-18T08:09:43Z