digitalmars.D.bugs - [Issue 6888] New: std.getopt.getopt: one-letter hash option causes range violation
- d-bugmail puremagic.com (33/33) Nov 03 2011 http://d.puremagic.com/issues/show_bug.cgi?id=6888
- d-bugmail puremagic.com (28/28) Nov 03 2011 http://d.puremagic.com/issues/show_bug.cgi?id=6888
- d-bugmail puremagic.com (12/12) Nov 14 2011 http://d.puremagic.com/issues/show_bug.cgi?id=6888
http://d.puremagic.com/issues/show_bug.cgi?id=6888 Summary: std.getopt.getopt: one-letter hash option causes range violation Product: D Version: D2 Platform: x86_64 OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: Phobos AssignedTo: nobody puremagic.com ReportedBy: maximzms gmail.com --- Comment #0 from Maksim Zholudev <maximzms gmail.com> 2011-11-03 08:48:03 PDT --- The following code causes the error: -------------------- import std.getopt; void main() { int[string] foo; auto args = ["", "-t", "a=1"]; getopt(args, "t", &foo); } -------------------- core.exception.RangeError std.getopt(519): Range violation -------------------- There is no error if bundling is turned on: getopt(args, config.bundling, "t", &foo); There is no error if the option contains more than one letter e.g. "--tune" -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 03 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6888 --- Comment #1 from Maksim Zholudev <maximzms gmail.com> 2011-11-03 09:58:06 PDT --- The bug is found! In std/getopt.d: If the option is not long and bundling is forbidden lines 587-588 are executed. If arg looks like "-t" value is empty but !value is false, i.e. in the following code all asserts are true: test.d: -------------------- void main() { string s = "t"; string s1 = s[1..$]; string s2 = null; assert(s1 == null); assert(s2 == null); assert(!s1 == false); // Why? assert(!s2 == true); } -------------------- Hence in std/getopt.d in the line 464: !val is false and val is empty when we come to line 519 and try to access its contents. I'm going to fix it right now. But the behavior of empty slices looks like a bug of the compiler. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 03 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6888 Kenji Hara <k.hara.pg gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED --- Comment #2 from Kenji Hara <k.hara.pg gmail.com> 2011-11-14 04:52:25 PST --- https://github.com/D-Programming-Language/phobos/pull/315 https://github.com/D-Programming-Language/phobos/commit/0ee6a1afbd8686a8051af4c86df9333c22daec89 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 14 2011